Skip to content

Conversation

@MikePuzanov
Copy link
Owner

No description provided.

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.

По существу всё правильно, но уж очень неаккуратно

Comment on lines 9 to 13
if ((!isCorrect1 || !isCorrect2) || (result1 != mainResult || result2 != mainResult))
{
return false;
}
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Какой ужас :) Просто return то, что написано в if


private bool CheckFalseExpression(bool isCorrect1, bool isCorrect2)
{
return (!isCorrect1 && !isCorrect2);
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

Choose a reason for hiding this comment

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

Тут, кстати, скобки лишние :)

return (!isCorrect1 && !isCorrect2);
}

[TestCase]
Copy link
Collaborator

Choose a reason for hiding this comment

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

На самом деле, просто Test, TestCase --- это если бы Вы параметры в метод передавали

{
private bool CheckTrueExpression(bool isCorrect1, bool isCorrect2, double result1, double result2, double mainResult)
{
if ((!isCorrect1 || !isCorrect2) || (result1 != mainResult || result2 != mainResult))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Оо, кто-то всё-таки сравнивает double-ы через !=. Это не совсем == и сравнение с нулём, но уровень непонимания представления вещественных чисел такой же :) См. https://0.30000000000000004.com/

IStack stack2 = new StackArray();
stack1.Push(9);
stack2.Push(8);
Assert.IsTrue((stack1.Pop() == 9 && stack2.Pop() == 8));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Правильнее было бы написать два Assert.AreEqual. Тут, если тест не пройдёт, Вам скажут "ну, тест не прошёл", а если сделать правильно, то напишут, что конкретно чему не равно, что упростит отладку

private static bool IsOperand(char symbol)
{
return symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/';
}
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

Choose a reason for hiding this comment

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

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

@@ -0,0 +1,60 @@
using NUnit.Framework;

namespace hw2Calculator.Test
Copy link
Collaborator

Choose a reason for hiding this comment

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

Пространства имён в .NET именуются с заглваной всегда

Copy link
Collaborator

Choose a reason for hiding this comment

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

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

public bool IsEmpty()
{
return countNumbersInStack == 0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тоже лучше через =>

return countNumbersInStack == 0;
}

public void DeleteStack()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Скорее, ClearStack, чтобы не смущать C++-ников и вообще. Мы же стек не удаляем, мы просто выкидываем все его элементы и возвращаем его в начальное состояние

MikePuzanov and others added 4 commits April 20, 2021 20:12
Co-authored-by: Yurii Litvinov <yurii.litvinov@gmail.com>
Co-authored-by: Yurii Litvinov <yurii.litvinov@gmail.com>
IStack stack1 = new StackList();
IStack stack2 = new StackArray();
(var result1, var isCorrect1) = Calculator.CalculatorExpression(expresion, stack1);
(var result2, var isCorrect2) = Calculator.CalculatorExpression(expresion, stack2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Условие "при этом не содержать дублирующегося кода" не выполнено. Посмотрите https://docs.nunit.org/articles/nunit/writing-tests/attributes/testcasesource.html и https://docs.nunit.org/articles/nunit/writing-tests/attributes/testcase.html

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.

Надо ещё немного поправить

@@ -0,0 +1,60 @@
using NUnit.Framework;

namespace hw2Calculator.Test
Copy link
Collaborator

Choose a reason for hiding this comment

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

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


private bool CheckFalseExpression(bool isCorrect1, bool isCorrect2)
{
return (!isCorrect1 && !isCorrect2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тут, кстати, скобки лишние :)

{
private bool CheckTrueExpression(bool isCorrect1, bool isCorrect2, double result1, double result2, double mainResult)
{
return (!isCorrect1 || !isCorrect2) || (result1 - mainResult < 0.000001 || result2 - mainResult < 0.000001);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ой, математика говорит, что если mainResult достаточно большой, эта штука его одобрит

return (0, false);
}

private static bool IsOperand(char symbol)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Скорее IsOperator

private static bool IsOperand(char symbol)
{
return symbol == '+' || symbol == '-' || symbol == '*' || symbol == '/';
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

return !isCorrect || Math.Abs(result - mainResult) < 0.000001;
}

private static (string Test, double Result)[] CorrectDataForTests = new[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Вообще, это поле, так что должно быть со строчной по идее

new TestCaseData(new StackArray(), DataForTests.Test, DataForTests.Result)
});

private static string[] UncorrectDataForTests = new[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

"IncorrectDataForTests"

Comment on lines 56 to 57
[TestCaseSource(nameof(CorrectDataForTest))]
public void CalculatorTestForUncorrectData(IStack stack, string expresion, double mainResult)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Что-то имя источника данных в TestCaseSource противоречит имени теста

Assert.IsTrue(CheckTrueExpression(isCorrect, result, mainResult));
}

private static IEnumerable<TestCaseData> UncorrectDataForTest
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 8 to 9
IStack stack1;
IStack stack2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

private

Comment on lines 14 to 15
stack1 = new StackList();
stack2 = new StackArray();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тут тоже стоило data-driven-тесты использовать, потому что стеки реализуют один интерфейс и обязаны вести себя одинаково


namespace Hw2Calculator
{
class Test
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 34 to 35
double delete = stackElements[countNumbersInStack];
return delete;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Но зачем? Это же просто return stackElements[countNumbersInStack];

public bool IsEmpty()
=> countNumbersInStack == 0;


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.

Да, теперь всё хорошо, зачтена

}

private static IEnumerable<TestCaseData> UncorrectDataForTest
private static IEnumerable<TestCaseData> TestIncorrectDate
Copy link
Collaborator

Choose a reason for hiding this comment

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

Date --- в смысле "свидание"?

private bool CheckTrueExpression(bool isCorrect, double result, double mainResult)
{
return !isCorrect || Math.Abs(result - mainResult) < 0.000001;
}
Copy link
Collaborator

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