-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Алешев Руслан #230
Open
artBETEP
wants to merge
2
commits into
kontur-courses:master
Choose a base branch
from
artBETEP:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Алешев Руслан #230
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,28 +16,29 @@ public void CheckCurrentTsar() | |
new Person("Vasili III of Russia", 28, 170, 60, null)); | ||
|
||
// Перепишите код на использование Fluent Assertions. | ||
Assert.AreEqual(actualTsar.Name, expectedTsar.Name); | ||
Assert.AreEqual(actualTsar.Age, expectedTsar.Age); | ||
Assert.AreEqual(actualTsar.Height, expectedTsar.Height); | ||
Assert.AreEqual(actualTsar.Weight, expectedTsar.Weight); | ||
|
||
Assert.AreEqual(expectedTsar.Parent!.Name, actualTsar.Parent!.Name); | ||
Assert.AreEqual(expectedTsar.Parent.Age, actualTsar.Parent.Age); | ||
Assert.AreEqual(expectedTsar.Parent.Height, actualTsar.Parent.Height); | ||
Assert.AreEqual(expectedTsar.Parent.Parent, actualTsar.Parent.Parent); | ||
} | ||
// Cравниваем все свойства, кроме исключенных | ||
actualTsar.Should().BeEquivalentTo(expectedTsar,options => options.Excluding(x=>x.Id).Excluding((x=>x.Parent!.Id))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Кажется, здесь есть лишняя пара скобочек. |
||
|
||
[Test] | ||
// Тесты описываются более естественным языком | ||
// Сообщения об ошибках более информативны | ||
// При добавлении новых полей для сравнения не нужно изменять тест | ||
|
||
} | ||
|
||
[Test] | ||
[Description("Альтернативное решение. Какие у него недостатки?")] | ||
public void CheckCurrentTsar_WithCustomEquality() | ||
{ | ||
var actualTsar = TsarRegistry.GetCurrentTsar(); | ||
var expectedTsar = new Person("Ivan IV The Terrible", 54, 170, 70, | ||
new Person("Vasili III of Russia", 28, 170, 60, null)); | ||
|
||
// Какие недостатки у такого подхода? | ||
Assert.True(AreEqual(actualTsar, expectedTsar)); | ||
} | ||
// Какие недостатки у такого подхода? | ||
//При добавлении свойств нужно изменять метод AreEquals | ||
//Неинформативное сообщение об ошибке - не понятно, в чем именно различаются объекты | ||
Assert.True(AreEqual(actualTsar, expectedTsar)); | ||
} | ||
|
||
private bool AreEqual(Person? actual, Person? expected) | ||
{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мало кейсов на позитивные сценарии. Мы никогда не знаем, какая часть логики поменяется, поэтому - фиксация позитивных сценариев важна точно так же, как и негативных.
Плюс один из параметров вообще в тестах нигде не учитывается, с ним бы тоже написать тестов.