Skip to content
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

Волков Кирилл #236

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions cs/HomeExercises/Tests/NumberValidator_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ public class NumberValidator_Should

private static IEnumerable IncorrectConstructorParamsTests()
{
yield return new TestCaseData(-1, 2, true)
yield return new TestCaseData(-1, 2, true, "precision must be a positive number")
.SetName("Constructor_ThrowsArgumentExceptionOnNegativePrecision");
yield return new TestCaseData(1, 2, true)
yield return new TestCaseData(0, 2, true, "precision must be a positive number")
.SetName("Constructor_ThrowsArgumentExceptionOnZeroPrecision");
yield return new TestCaseData(1, 2, true, "precision must be a non-negative number less or equal than precision")
.SetName("Constructor_ThrowsArgumentExceptionOnPrecisionLessThanScale");
yield return new TestCaseData(1, 1, true)
yield return new TestCaseData(1, 1, true, "precision must be a non-negative number less or equal than precision")
.SetName("Constructor_ThrowsArgumentExceptionSamePrecisionAndScale");
yield return new TestCaseData(1, -1, true)
yield return new TestCaseData(1, -1, true, "precision must be a non-negative number less or equal than precision")
.SetName("Constructor_ThrowsArgumentExceptionOnNegativeScale");
}

Expand Down Expand Up @@ -100,12 +102,12 @@ private static IEnumerable IsValidNumberValueTests()
#endregion

[TestCaseSource(nameof(IncorrectConstructorParamsTests))]
public void FailsWithIncorrectConstructorArguments(int precision, int scale, bool onlyPositive)
public void FailsWithIncorrectConstructorArguments(int precision, int scale, bool onlyPositive, string message)
{
new Func<NumberValidator>(() => new NumberValidator(precision, scale, onlyPositive))
.Should()
.ThrowExactly<ArgumentException>()
.Where(e => e.Message.Contains("precision"));
.Where(e => e.Message.Equals(message, StringComparison.OrdinalIgnoreCase));
}

[TestCaseSource(nameof(CorrectConstructorParamsTests))]
Expand Down
6 changes: 2 additions & 4 deletions cs/HomeExercises/Tests/ObjectComparsion_Should.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Equivalency;
using NUnit.Framework;

namespace HomeExercises.Tests
Expand All @@ -24,10 +25,7 @@ public void CheckCurrentTsar()
actualTsar.Should().BeEquivalentTo(expectedTsar, options =>
options
.IncludingFields()
.Excluding(p => p.Id)
.Excluding(p => p.Parent!.Id)
.Excluding(p => p.Parent!.Weight)
.Excluding(p => p.Parent!.Parent)
.Excluding(memberInfo => memberInfo.SelectedMemberInfo.Name == "Id")

Choose a reason for hiding this comment

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

Давай представим:

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

);
}

Expand Down