-
Notifications
You must be signed in to change notification settings - Fork 32
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
Бабинцев Григорий #21
Open
qreaqtor
wants to merge
5
commits into
kontur-courses:master
Choose a base branch
from
qreaqtor:testing-homework
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
Changes from 4 commits
Commits
Show all changes
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
| ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.11.35327.3 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Basic", "Basic.csproj", "{ECC863AA-4C3E-4E5C-A2D0-459A2A1D33A3}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{ECC863AA-4C3E-4E5C-A2D0-459A2A1D33A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{ECC863AA-4C3E-4E5C-A2D0-459A2A1D33A3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{ECC863AA-4C3E-4E5C-A2D0-459A2A1D33A3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{ECC863AA-4C3E-4E5C-A2D0-459A2A1D33A3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {2B8F6D26-176B-4CA4-8C5B-A15FA83E5325} | ||
EndGlobalSection | ||
EndGlobal |
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
90 changes: 67 additions & 23 deletions
90
Testing/Basic/Homework/2. NumberValidator/NumberValidatorTests.cs
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 |
---|---|---|
@@ -1,31 +1,75 @@ | ||
| ||
using FluentAssertions; | ||
using Newtonsoft.Json.Linq; | ||
using NUnit.Framework; | ||
using NUnit.Framework.Legacy; | ||
using System.Collections; | ||
|
||
namespace HomeExercise.Tasks.NumberValidator; | ||
|
||
|
||
|
||
[TestFixture] | ||
public class NumberValidatorTests | ||
public partial class NumberValidatorTests | ||
{ | ||
[Test] | ||
public void Test() | ||
{ | ||
Assert.Throws<ArgumentException>(() => new NumberValidator(-1, 2, true)); | ||
Assert.DoesNotThrow(() => new NumberValidator(1, 0, true)); | ||
Assert.Throws<ArgumentException>(() => new NumberValidator(-1, 2, false)); | ||
Assert.DoesNotThrow(() => new NumberValidator(1, 0, true)); | ||
|
||
ClassicAssert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0.0")); | ||
ClassicAssert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0")); | ||
ClassicAssert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0.0")); | ||
ClassicAssert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("00.00")); | ||
ClassicAssert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("-0.00")); | ||
ClassicAssert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0.0")); | ||
ClassicAssert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("+0.00")); | ||
ClassicAssert.IsTrue(new NumberValidator(4, 2, true).IsValidNumber("+1.23")); | ||
ClassicAssert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("+1.23")); | ||
ClassicAssert.IsFalse(new NumberValidator(17, 2, true).IsValidNumber("0.000")); | ||
ClassicAssert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("-1.23")); | ||
ClassicAssert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("a.sd")); | ||
} | ||
|
||
[TestCase(17, 1, true, "0.0", TestName = "Number with point separator")] | ||
[TestCase(17, 1, true, "0,0", TestName = "Number with comma separator")] | ||
[TestCase(17, 2, true, "0", TestName = "Number without fractionl part")] | ||
[TestCase(4, 1, true, "1234", TestName = "Number length equals to precision")] | ||
[TestCase(17, 1, true, "+1,0", TestName = "Positive number with comma")] | ||
[TestCase(4, 1, true, "+123", TestName = "Positive number length with equals to precision")] | ||
[TestCase(4, 1, true, "+12.3", TestName = "Positive number length with fractionl part equals to precision")] | ||
[TestCase(5, 3, true, "+1.000", TestName = "Positive number length with fractional part equals to precision")] | ||
[TestCase(17, 1, false, "-1,0", TestName = "Negative number with comma")] | ||
[TestCase(4, 1, false, "-123", TestName = "Negative number length with plus equals to precision")] | ||
[TestCase(4, 1, false, "-12.3", TestName = "Negative number length with frctionl part equals to precision")] | ||
[TestCase(5, 3, false, "-1.000", TestName = "Negative number length with fractional part and plus equals to precision")] | ||
|
||
public void IsValidNumber_Shoud_BeTrue_WhenArgsCorrect(int precision, int scale, bool onlyPositive, string value) | ||
{ | ||
var validator = new NumberValidator(precision, scale, onlyPositive); | ||
|
||
var result = validator.IsValidNumber(value); | ||
|
||
result.Should().BeTrue(); | ||
} | ||
|
||
|
||
[TestCase(3, 2, true, "00.00", TestName = "Number length with fractionl part more than precision")] | ||
[TestCase(3, 2, true, "-0.0", TestName = "Negative number length with fractionl part more than precision")] | ||
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. А этот тест проверяет не то, что указано в описании. Но сам тест хороший |
||
[TestCase(3, 2, true, "+0.00", TestName = "Positive number length with fractionl part more than precision")] | ||
[TestCase(3, 2, true, "a.sd", TestName = "Number consists letters")] | ||
[TestCase(17, 2, true, "0.000", TestName = "Length number's frationl part more thn scale")] | ||
[TestCase(3, 2, true, "", TestName = "Number is empty string")] | ||
[TestCase(3, 2, true, null, TestName = "Number is null")] | ||
[TestCase(4, 2, false, "10*00", TestName = "Number with invalid separator")] | ||
[TestCase(4, 1, false, "1.0.0", TestName = "Number with more than one separator")] | ||
public void IsValidNumber_Shoud_BeFalse_WhenArgsBad(int precision, int scale, bool onlyPositive, string value) | ||
{ | ||
var validator = new NumberValidator(precision, scale, onlyPositive); | ||
|
||
var result = validator.IsValidNumber(value); | ||
|
||
result.Should().BeFalse(); | ||
} | ||
|
||
|
||
[TestCase(-1, 2, TestName = "Negative precision")] | ||
[TestCase(1, -2, TestName = "Negative scale")] | ||
[TestCase(1, 2, TestName = "Precision less than scale")] | ||
[TestCase(1, 1, TestName = "Precision equals with scale")] | ||
public void Should_Throw_ArgumentException(int precision, int scale) | ||
{ | ||
var action = () => new NumberValidator(precision, scale); | ||
action.Should().Throw<ArgumentException>(); | ||
} | ||
|
||
|
||
[TestCase(1, 0, TestName = "Zero scale")] | ||
[TestCase(2, 1, TestName = "Precision more than scale")] | ||
public void Should_NotThrow_AnyException(int precision, int scale) | ||
{ | ||
var action = () => new NumberValidator(precision, scale); | ||
action.Should().NotThrow(); | ||
} | ||
} |
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.
Совет на будущее: хорошая привычка пересматривать изменения перед коммитом или пушем, чтобы ненужные изменения не попадали в общий репозиторий. Здесь сыграли злую шутку табы и пробелы, решается просто настройкой IDE