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

Трофимов Никита #239

Open
wants to merge 4 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
Prev Previous commit
Next Next commit
Изменил имена файлов
Добавил по тесту с onlyPositive = true
Доработал нейминг тестов
  • Loading branch information
WoeromProg committed Nov 30, 2023
commit 6a3a718c85588bee5032f949b09ae7d1705be75f
1 change: 1 addition & 0 deletions cs/Challenge/Challenge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit.Engine" Version="3.11.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="System.Security.Permissions" Version="4.7.0" />
</ItemGroup>

Expand Down
3 changes: 2 additions & 1 deletion cs/HomeExercises/HomeExercises.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="NUnit.Engine" Version="3.16.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Text.RegularExpressions;


namespace HomeExercises
{
public class NumberValidator
Expand Down
File renamed without changes.
53 changes: 26 additions & 27 deletions cs/HomeExercises/tests/NumberValidator_Should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ namespace HomeExercises.tests
{
public class NumberValidator_Should
{
[TestCase(-1, 2, TestName = "NegativePrecision")]
[TestCase(0, 0, TestName = "PrecisionIsZero")]
[TestCase(3, -1, TestName = "NegativeScale")]
[TestCase(1, 2, TestName = "ScaleIsGreaterThanPrecision")]
[TestCase(1, 1, TestName = "PrecisionEqualsScale")]
public void Creation_ShouldThrowArgumentException(int precision, int scale)
[TestCase(-1, 2, false, TestName = "NegativePrecision")]
[TestCase(0, 0, false, TestName = "PrecisionIsZero")]
[TestCase(3, -1, false, TestName = "NegativeScale")]
[TestCase(1, 2, false, TestName = "ScaleIsGreaterThanPrecision")]
[TestCase(1, 1, true, TestName = "PrecisionEqualsScale")]
public void Creation_ShouldThrowArgumentException(int precision, int scale, bool onlyPositive)
{
Action creation = () => new NumberValidator(precision, scale);
Action creation = () => new NumberValidator(precision, scale, onlyPositive);
creation.Should().Throw<ArgumentException>();
}

[Test]
public void Creation_ShouldNotThrow()
{
Expand All @@ -27,28 +26,28 @@ public void Creation_ShouldNotThrow()

Choose a reason for hiding this comment

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

Лишняя строка пустая

}

[TestCase(3, 2,"-+0.0", TestName = "TwoSigns")]
[TestCase(3, 2," -0.0", TestName = "SpaceFirstDigitInNumber")]
[TestCase(3, 2,"0,", TestName ="Aren'tDigitsAfterCommas")]
[TestCase(3, 2,"0.0.0", TestName = "ThreeDigitsInNumberByTwoDots")]
[TestCase(3, 2,"0,0,0", TestName = "ThreeDigitsInNumberByTwoCommas")]
[TestCase(3, 2, "00.00", TestName = "NumberPrecisionGreaterThanValidatorPrecision")]
[TestCase(3, 2, null, TestName = "NumberNull")]
[TestCase(3, 2, "", TestName = "NumberEmpty")]
[TestCase(3, 2, "+1.23", TestName = "NumberPrecisionGreaterThanValidatorPrecision")]
[TestCase(3, 2, "-1.23", TestName = "NumberNegativeInNumberOnlyPositive")]
[TestCase(17, 2, "0.000", TestName = "NumberScaleGreaterThanValidatorScale")]
[TestCase(17, 2, "a.sd", TestName = "IncorrectNumberFormatBecauseLettersArePresent")]
public void IsValidNumber_False(int precision, int scale, string number)
[TestCase(3, 2, false, "-+0.0", TestName = "TwoSigns")]
[TestCase(3, 2, false, " -0.0", TestName = "SpaceFirstDigitInNumber")]
[TestCase(3, 2, false, "0,", TestName ="Aren'tDigitsAfterCommas")]
[TestCase(3, 2, false, "0.0.0", TestName = "ThreeDigitsInNumberByTwoDots")]
[TestCase(3, 2, false, "0,0,0", TestName = "ThreeDigitsInNumberByTwoCommas")]
[TestCase(3, 2, false, "00.00", TestName = "NumberPrecisionGreaterThanValidatorPrecision")]
[TestCase(3, 2, false, null, TestName = "NumberNull")]
[TestCase(3, 2, false, "", TestName = "NumberEmpty")]
[TestCase(3, 2, false, "+1.23", TestName = "NumberPrecisionGreaterThanValidatorPrecision")]
[TestCase(3, 2, false, "-1.23", TestName = "NumberNegativeInNumberOnlyPositive")]
[TestCase(17, 2, true, "0.000", TestName = "NumberScaleGreaterThanValidatorScale")]
[TestCase(17, 2, true, "a.sd", TestName = "IncorrectNumberFormatBecauseLettersArePresent")]
public void IsValidNumber_ShouldFalse_When(int precision, int scale, bool onlyPositive, string number)
{
var validator = new NumberValidator(precision, scale);
var validator = new NumberValidator(precision, scale, onlyPositive);
validator.IsValidNumber(number).Should().BeFalse();
}
[TestCase(17, 2, "0.0", TestName = "NumberWithFractionalPart")]
[TestCase(17, 2, "0", TestName = "OnlyInteger")]
[TestCase(4, 2, "+1.23", TestName = "NumberWithSign")]
public void IsValidNumber_True(int precision, int scale, string number)

[TestCase(17, 2, false, "0.0", TestName = "NumberWithFractionalPart")]
[TestCase(17, 2, false, "0", TestName = "OnlyInteger")]
[TestCase(4, 2, true, "+1.23", TestName = "NumberWithSign")]
public void IsValidNumber_ShouldTrue_When(int precision, int scale, bool onlyPositive, string number)
{
var validator = new NumberValidator(precision, scale);
validator.IsValidNumber(number).Should().BeTrue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using FluentAssertions;
using NUnit.Framework;


namespace HomeExercises.tests
{
public class ObjectComparsion_Should
public class Person_Should
{
[Test]
[Description("Проверка текущего царя")]
Expand Down
1 change: 0 additions & 1 deletion cs/Samples/Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>

<ItemGroup>
Expand Down