Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

list.DeleteByIndex(2);
list.DeleteByIndex(7);
list.DeleteByIndex(1);
Assert.IsFalse(list.IsConsist(2) || list.IsConsist(8) || list.IsConsist(1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше разбить на отдельные Assert-ы, чтобы если что пойдёт не так, сразу знать, в чём дело

[TestCase]
public void TestGetSize()
{
Assert.IsTrue(list.GetSize() == 8);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AreEqual лучше

/// </summary>
public class List
{
private int Size { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private-свойства вообще довольно бесполезны, поскольку находятся "внутри" инкапсуляции класса. Их можно заменить на поля всегда.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не поправлено

Comment on lines 29 to 30
Size = 0;
head = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Они и так null и 0, можно конструктор вообще не писать


private Node head;

private Node runner;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это временная переменная, которая не является на самом деле частью состояния объекта, не надо её делать полем (а то забудете сбросить где-нибудь и будут труднообнаружимые ошибки)

Comment on lines 21 to 37
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);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем? Методы предка ведь делают то же самое

if (possition > GetSize() || possition < 1)
{
throw new IndexOutOfRangeException();
}

This comment was marked as resolved.

}
else if (IsConsist(value))
{
throw new ValueIsAlreadyInListException("Такое значение уже есть в списке!");

This comment was marked as resolved.


namespace hw4UniqueList
{
public class ValueDoesNotExistException : Exception

This comment was marked as resolved.


namespace hw4UniqueList
{
public class ValueIsAlreadyInListException : Exception

This comment was marked as resolved.

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо доисправлять

list.DeleteByValue(2);
list.DeleteByValue(8);
list.DeleteByValue(1);
Assert.IsFalse(list.Contains(2) || list.Contains(8) || list.Contains(1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Где-то разбили на ассерты, а тут нет

[TestCase]
public void TestGetSize()
{
Assert.AreEqual(list.GetSize(), 8);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наоборот, сначала ожидаемое значение, потом то, что получилось. Иначе сообщения об ошибках будут неправильными

/// </summary>
public class List
{
private int Size { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не поправлено

base.DeleteByValue(value);
}

public override void ChangeByIndex(int possition, int value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

position

Comment on lines 21 to 24
public override int DeleteByIndex(int possition)
{
return base.DeleteByIndex(possition);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если потомок ничего не добавляет, то переопределение и не нужно. Если потомок не переопределяет виртуальный метод предка, то будет сразу метод предка вызываться.

using NUnit.Framework;
using System;

namespace hw4UniqueList.Test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нэймспейсы бы ещё с заглавной...

Copy link
Collaborator

@yurii-litvinov yurii-litvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ага, зачтена

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants