Conversation
| list.DeleteByIndex(2); | ||
| list.DeleteByIndex(7); | ||
| list.DeleteByIndex(1); | ||
| Assert.IsFalse(list.IsConsist(2) || list.IsConsist(8) || list.IsConsist(1)); |
There was a problem hiding this comment.
Лучше разбить на отдельные Assert-ы, чтобы если что пойдёт не так, сразу знать, в чём дело
| [TestCase] | ||
| public void TestGetSize() | ||
| { | ||
| Assert.IsTrue(list.GetSize() == 8); |
hw4UniqueList/hw4UniqueList/List.cs
Outdated
| /// </summary> | ||
| public class List | ||
| { | ||
| private int Size { get; set; } |
There was a problem hiding this comment.
private-свойства вообще довольно бесполезны, поскольку находятся "внутри" инкапсуляции класса. Их можно заменить на поля всегда.
hw4UniqueList/hw4UniqueList/List.cs
Outdated
| Size = 0; | ||
| head = null; |
There was a problem hiding this comment.
Они и так null и 0, можно конструктор вообще не писать
hw4UniqueList/hw4UniqueList/List.cs
Outdated
|
|
||
| private Node head; | ||
|
|
||
| private Node runner; |
There was a problem hiding this comment.
Это временная переменная, которая не является на самом деле частью состояния объекта, не надо её делать полем (а то забудете сбросить где-нибудь и будут труднообнаружимые ошибки)
| public override int DeleteByIndex(int possition) | ||
| { | ||
| if (possition > GetSize() || possition < 1) | ||
| { | ||
| throw new IndexOutOfRangeException(); | ||
| } | ||
| return base.DeleteByIndex(possition); | ||
| } | ||
|
|
||
| public override void DeleteByValue(int value) | ||
| { | ||
| if (!IsConsist(value)) | ||
| { | ||
| throw new ValueDoesNotExistException("Такого значения в списке не существует!"); | ||
| } | ||
| base.DeleteByValue(value); | ||
| } |
There was a problem hiding this comment.
Зачем? Методы предка ведь делают то же самое
| if (possition > GetSize() || possition < 1) | ||
| { | ||
| throw new IndexOutOfRangeException(); | ||
| } |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| } | ||
| else if (IsConsist(value)) | ||
| { | ||
| throw new ValueIsAlreadyInListException("Такое значение уже есть в списке!"); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| namespace hw4UniqueList | ||
| { | ||
| public class ValueDoesNotExistException : Exception |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| namespace hw4UniqueList | ||
| { | ||
| public class ValueIsAlreadyInListException : Exception |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
yurii-litvinov
left a comment
There was a problem hiding this comment.
Надо доисправлять
| list.DeleteByValue(2); | ||
| list.DeleteByValue(8); | ||
| list.DeleteByValue(1); | ||
| Assert.IsFalse(list.Contains(2) || list.Contains(8) || list.Contains(1)); |
There was a problem hiding this comment.
Где-то разбили на ассерты, а тут нет
| [TestCase] | ||
| public void TestGetSize() | ||
| { | ||
| Assert.AreEqual(list.GetSize(), 8); |
There was a problem hiding this comment.
Наоборот, сначала ожидаемое значение, потом то, что получилось. Иначе сообщения об ошибках будут неправильными
hw4UniqueList/hw4UniqueList/List.cs
Outdated
| /// </summary> | ||
| public class List | ||
| { | ||
| private int Size { get; set; } |
| base.DeleteByValue(value); | ||
| } | ||
|
|
||
| public override void ChangeByIndex(int possition, int value) |
| public override int DeleteByIndex(int possition) | ||
| { | ||
| return base.DeleteByIndex(possition); | ||
| } |
There was a problem hiding this comment.
Если потомок ничего не добавляет, то переопределение и не нужно. Если потомок не переопределяет виртуальный метод предка, то будет сразу метод предка вызываться.
| using NUnit.Framework; | ||
| using System; | ||
|
|
||
| namespace hw4UniqueList.Test |
There was a problem hiding this comment.
Нэймспейсы бы ещё с заглавной...
No description provided.