From e5c6bb59dd9781d43d88e2b590346c011e306e26 Mon Sep 17 00:00:00 2001 From: tripples25 <92451706+tripples25@users.noreply.github.com> Date: Tue, 28 Nov 2023 02:14:33 +0500 Subject: [PATCH 1/7] Rewrite CheckCurrentTsar on using FluentAssertions --- cs/HomeExercises/ObjectComparison.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/cs/HomeExercises/ObjectComparison.cs b/cs/HomeExercises/ObjectComparison.cs index 44d9aed4..07f414d2 100644 --- a/cs/HomeExercises/ObjectComparison.cs +++ b/cs/HomeExercises/ObjectComparison.cs @@ -7,24 +7,18 @@ public class ObjectComparison { [Test] [Description("Проверка текущего царя")] - [Category("ToRefactor")] public void CheckCurrentTsar() { 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)); - - // Перепишите код на использование 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); + + actualTsar + .Should() + .BeEquivalentTo(expectedTsar, options => options + .Excluding(memberInfo => memberInfo.SelectedMemberInfo.DeclaringType == typeof(Person) + && memberInfo.SelectedMemberInfo.Name == nameof(Person.Id))); } [Test] @@ -56,8 +50,7 @@ public class TsarRegistry { public static Person GetCurrentTsar() { - return new Person( - "Ivan IV The Terrible", 54, 170, 70, + return new Person("Ivan IV The Terrible", 54, 170, 70, new Person("Vasili III of Russia", 28, 170, 60, null)); } } From 3deaa3c8f4ca4afbf55e05d7ed2669058e7b84c4 Mon Sep 17 00:00:00 2001 From: tripples25 <92451706+tripples25@users.noreply.github.com> Date: Tue, 28 Nov 2023 06:01:33 +0500 Subject: [PATCH 2/7] Refactored NumberValidatorTests and added missing tests --- cs/HomeExercises/NumberValidatorTests.cs | 64 +++++++++++++++++------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/cs/HomeExercises/NumberValidatorTests.cs b/cs/HomeExercises/NumberValidatorTests.cs index a2878113..a7425c2c 100644 --- a/cs/HomeExercises/NumberValidatorTests.cs +++ b/cs/HomeExercises/NumberValidatorTests.cs @@ -5,28 +5,54 @@ namespace HomeExercises { + [TestFixture] public class NumberValidatorTests { - [Test] - public void Test() + [TestCase(0, 2, true, TestName = "precision is zero")] + [TestCase(-1, 2, true, TestName = "precision is negative")] + [TestCase(1, -1, false, TestName = "scale is negative")] + [TestCase(1, 2, false, TestName = "scale is greater than precision")] + [TestCase(1, 1, false, TestName = "scale is equals precision")] + public void Constructor_Fails_OnIncorrectArguments(int precision, int scale, bool onlyPositive) { - Assert.Throws(() => new NumberValidator(-1, 2, true)); - Assert.DoesNotThrow(() => new NumberValidator(1, 0, true)); - Assert.Throws(() => new NumberValidator(-1, 2, false)); - Assert.DoesNotThrow(() => new NumberValidator(1, 0, true)); - - Assert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0.0")); - Assert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0")); - Assert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0.0")); - Assert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("00.00")); - Assert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("-0.00")); - Assert.IsTrue(new NumberValidator(17, 2, true).IsValidNumber("0.0")); - Assert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("+0.00")); - Assert.IsTrue(new NumberValidator(4, 2, true).IsValidNumber("+1.23")); - Assert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("+1.23")); - Assert.IsFalse(new NumberValidator(17, 2, true).IsValidNumber("0.000")); - Assert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("-1.23")); - Assert.IsFalse(new NumberValidator(3, 2, true).IsValidNumber("a.sd")); + Action a = () => { new NumberValidator(precision, scale, onlyPositive); }; + a.Should().Throw(); + } + + [TestCase(1, 0, true, TestName = "with all arguments")] + public void Constructor_Success_OnCorrectArguments(int precision, int scale, bool onlyPositive) + { + Action a = () => { new NumberValidator(precision, scale, onlyPositive); }; + a.Should().NotThrow(); + } + + [TestCase(3, 2, true, null, TestName = "value is null")] + [TestCase(3, 2, true, "", TestName = "value is empty")] + [TestCase(3, 2, true, "+1..23", TestName = "value has incorrect format")] + [TestCase(17, 2, true, "0.000", TestName = "value's fraction part length is greater than scale")] + [TestCase(5, 2, true, "-0.00", TestName = "negative sign when onlyPositive is true")] + [TestCase(3, 2, true, "+0.00", TestName = "intPart and fractPart together is greater than precision")] + public void IsValidNumber_ReturnsFalse_OnIncorrectArguments(int precision, int scale, bool onlyPositive, string value) + { + new NumberValidator(precision, scale, onlyPositive) + .IsValidNumber(value) + .Should() + .BeFalse(); + } + + [TestCase(17, 2, true, "0", TestName = "value without sign")] + [TestCase(17, 2, true, "+0", TestName = "value with positive sign")] + [TestCase(17, 2, false, "-0", TestName = "value with negative sign")] + [TestCase(17, 2, true, "0.0", TestName = "value with period as delimiter")] + [TestCase(17, 2, true, "0,0", TestName = "value with comma as delimiter")] + [TestCase(17, 2, true, "+0,0", TestName = "value with sign and delimiter")] + [TestCase(40, 20, true, "1234567890", TestName = "value with different numbers")] + public void IsValidNumber_ReturnsTrue_OnCorrectArguments(int precision, int scale, bool onlyPositive, string value) + { + new NumberValidator(precision, scale, onlyPositive) + .IsValidNumber(value) + .Should() + .BeTrue(); } } From d100a68fffc8166c49852912d449cfd843246fcc Mon Sep 17 00:00:00 2001 From: tripples25 <92451706+tripples25@users.noreply.github.com> Date: Tue, 28 Nov 2023 06:29:13 +0500 Subject: [PATCH 3/7] Added an answer to the question --- cs/HomeExercises/ObjectComparison.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cs/HomeExercises/ObjectComparison.cs b/cs/HomeExercises/ObjectComparison.cs index 07f414d2..2653e508 100644 --- a/cs/HomeExercises/ObjectComparison.cs +++ b/cs/HomeExercises/ObjectComparison.cs @@ -23,6 +23,17 @@ public void CheckCurrentTsar() [Test] [Description("Альтернативное решение. Какие у него недостатки?")] + /* 1. Непонятно из названия, что тест проверяет и какого результата ожидает. + * 2. При использовании такого Assert, при падении теста мы узнаем лишь, что мы получили False, + * без дополнительной информации об отличающихся полях и т.д. + * 3. При изменении класса Person нам всегда придётся соответственно менять и локальный метод + * AreEqual для класса Person. + * 4. Если каким-то образом произойдёт бесконечная рекурсия внутри класса Person, то данный способ привдёт к + * бесконечному проходу по нему. Проверка через FluentAssertions ограничена глубиной + * в 10 вхождений и это значение кастомизируемо. + * 5. При добавлении новых полей в класс Person, которые мы хотим включать в этот Equals - метод может + * сильно разрастись и его читаемость сильно снизится. + */ public void CheckCurrentTsar_WithCustomEquality() { var actualTsar = TsarRegistry.GetCurrentTsar(); From b0124c52364b1c181ecb96c00c19849a23c1a11c Mon Sep 17 00:00:00 2001 From: tripples25 <92451706+tripples25@users.noreply.github.com> Date: Wed, 29 Nov 2023 07:04:22 +0500 Subject: [PATCH 4/7] Split files in HomeExercises in separate classes --- cs/HomeExercises/HomeExercises.csproj | 2 +- .../NumberValidator/NumberValidator.cs | 53 +++++++++++++++++++ .../NumberValidatorTests.cs | 52 +----------------- cs/HomeExercises/Person.cs | 21 ++++++++ cs/HomeExercises/TsarRegistry/TsarRegistry.cs | 11 ++++ .../TsarRegistryTests.cs} | 34 ++---------- 6 files changed, 91 insertions(+), 82 deletions(-) create mode 100644 cs/HomeExercises/NumberValidator/NumberValidator.cs rename cs/HomeExercises/{ => NumberValidator}/NumberValidatorTests.cs (50%) create mode 100644 cs/HomeExercises/Person.cs create mode 100644 cs/HomeExercises/TsarRegistry/TsarRegistry.cs rename cs/HomeExercises/{ObjectComparison.cs => TsarRegistry/TsarRegistryTests.cs} (81%) diff --git a/cs/HomeExercises/HomeExercises.csproj b/cs/HomeExercises/HomeExercises.csproj index ede81aec..14244f22 100644 --- a/cs/HomeExercises/HomeExercises.csproj +++ b/cs/HomeExercises/HomeExercises.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0-windows false HomeExercises ObjectComparison diff --git a/cs/HomeExercises/NumberValidator/NumberValidator.cs b/cs/HomeExercises/NumberValidator/NumberValidator.cs new file mode 100644 index 00000000..f6904677 --- /dev/null +++ b/cs/HomeExercises/NumberValidator/NumberValidator.cs @@ -0,0 +1,53 @@ +using System; +using System.Text.RegularExpressions; + +namespace HomeExercises.NumberValidator +{ + public class NumberValidator + { + private readonly Regex numberRegex; + private readonly bool onlyPositive; + private readonly int precision; + private readonly int scale; + + public NumberValidator(int precision, int scale = 0, bool onlyPositive = false) + { + this.precision = precision; + this.scale = scale; + this.onlyPositive = onlyPositive; + if (precision <= 0) + throw new ArgumentException("precision must be a positive number"); + if (scale < 0 || scale >= precision) + throw new ArgumentException("precision must be a non-negative number less or equal than precision"); + numberRegex = new Regex(@"^([+-]?)(\d+)([.,](\d+))?$", RegexOptions.IgnoreCase); + } + + public bool IsValidNumber(string value) + { + // Проверяем соответствие входного значения формату N(m,k), в соответствии с правилом, + // описанным в Формате описи документов, направляемых в налоговый орган в электронном виде по телекоммуникационным каналам связи: + // Формат числового значения указывается в виде N(m.к), где m – максимальное количество знаков в числе, включая знак (для отрицательного числа), + // целую и дробную часть числа без разделяющей десятичной точки, k – максимальное число знаков дробной части числа. + // Если число знаков дробной части числа равно 0 (т.е. число целое), то формат числового значения имеет вид N(m). + + if (string.IsNullOrEmpty(value)) + return false; + + var match = numberRegex.Match(value); + if (!match.Success) + return false; + + // Знак и целая часть + var intPart = match.Groups[1].Value.Length + match.Groups[2].Value.Length; + // Дробная часть + var fracPart = match.Groups[4].Value.Length; + + if (intPart + fracPart > precision || fracPart > scale) + return false; + + if (onlyPositive && match.Groups[1].Value == "-") + return false; + return true; + } + } +} \ No newline at end of file diff --git a/cs/HomeExercises/NumberValidatorTests.cs b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs similarity index 50% rename from cs/HomeExercises/NumberValidatorTests.cs rename to cs/HomeExercises/NumberValidator/NumberValidatorTests.cs index a7425c2c..43e96a60 100644 --- a/cs/HomeExercises/NumberValidatorTests.cs +++ b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs @@ -1,9 +1,8 @@ using System; -using System.Text.RegularExpressions; using FluentAssertions; using NUnit.Framework; -namespace HomeExercises +namespace HomeExercises.NumberValidator { [TestFixture] public class NumberValidatorTests @@ -25,7 +24,7 @@ public void Constructor_Success_OnCorrectArguments(int precision, int scale, boo Action a = () => { new NumberValidator(precision, scale, onlyPositive); }; a.Should().NotThrow(); } - + [TestCase(3, 2, true, null, TestName = "value is null")] [TestCase(3, 2, true, "", TestName = "value is empty")] [TestCase(3, 2, true, "+1..23", TestName = "value has incorrect format")] @@ -56,51 +55,4 @@ public void IsValidNumber_ReturnsTrue_OnCorrectArguments(int precision, int scal } } - public class NumberValidator - { - private readonly Regex numberRegex; - private readonly bool onlyPositive; - private readonly int precision; - private readonly int scale; - - public NumberValidator(int precision, int scale = 0, bool onlyPositive = false) - { - this.precision = precision; - this.scale = scale; - this.onlyPositive = onlyPositive; - if (precision <= 0) - throw new ArgumentException("precision must be a positive number"); - if (scale < 0 || scale >= precision) - throw new ArgumentException("precision must be a non-negative number less or equal than precision"); - numberRegex = new Regex(@"^([+-]?)(\d+)([.,](\d+))?$", RegexOptions.IgnoreCase); - } - - public bool IsValidNumber(string value) - { - // Проверяем соответствие входного значения формату N(m,k), в соответствии с правилом, - // описанным в Формате описи документов, направляемых в налоговый орган в электронном виде по телекоммуникационным каналам связи: - // Формат числового значения указывается в виде N(m.к), где m – максимальное количество знаков в числе, включая знак (для отрицательного числа), - // целую и дробную часть числа без разделяющей десятичной точки, k – максимальное число знаков дробной части числа. - // Если число знаков дробной части числа равно 0 (т.е. число целое), то формат числового значения имеет вид N(m). - - if (string.IsNullOrEmpty(value)) - return false; - - var match = numberRegex.Match(value); - if (!match.Success) - return false; - - // Знак и целая часть - var intPart = match.Groups[1].Value.Length + match.Groups[2].Value.Length; - // Дробная часть - var fracPart = match.Groups[4].Value.Length; - - if (intPart + fracPart > precision || fracPart > scale) - return false; - - if (onlyPositive && match.Groups[1].Value == "-") - return false; - return true; - } - } } \ No newline at end of file diff --git a/cs/HomeExercises/Person.cs b/cs/HomeExercises/Person.cs new file mode 100644 index 00000000..d4922662 --- /dev/null +++ b/cs/HomeExercises/Person.cs @@ -0,0 +1,21 @@ +namespace HomeExercises +{ + public class Person + { + public static int IdCounter = 0; + public int Age, Height, Weight; + public string Name; + public Person? Parent; + public int Id; + + public Person(string name, int age, int height, int weight, Person? parent) + { + Id = IdCounter++; + Name = name; + Age = age; + Height = height; + Weight = weight; + Parent = parent; + } + } +} \ No newline at end of file diff --git a/cs/HomeExercises/TsarRegistry/TsarRegistry.cs b/cs/HomeExercises/TsarRegistry/TsarRegistry.cs new file mode 100644 index 00000000..68e62c3a --- /dev/null +++ b/cs/HomeExercises/TsarRegistry/TsarRegistry.cs @@ -0,0 +1,11 @@ +namespace HomeExercises.TsarRegistry +{ + public class TsarRegistry + { + public static Person GetCurrentTsar() + { + return new Person("Ivan IV The Terrible", 54, 170, 70, + new Person("Vasili III of Russia", 28, 170, 60, null)); + } + } +} \ No newline at end of file diff --git a/cs/HomeExercises/ObjectComparison.cs b/cs/HomeExercises/TsarRegistry/TsarRegistryTests.cs similarity index 81% rename from cs/HomeExercises/ObjectComparison.cs rename to cs/HomeExercises/TsarRegistry/TsarRegistryTests.cs index 2653e508..6214e12e 100644 --- a/cs/HomeExercises/ObjectComparison.cs +++ b/cs/HomeExercises/TsarRegistry/TsarRegistryTests.cs @@ -1,13 +1,13 @@ using FluentAssertions; using NUnit.Framework; -namespace HomeExercises +namespace HomeExercises.TsarRegistry { - public class ObjectComparison + public class TsarRegistryTests { [Test] [Description("Проверка текущего царя")] - public void CheckCurrentTsar() + public void GetCurrentTsar_ReturnsCorrectTsar() { var actualTsar = TsarRegistry.GetCurrentTsar(); @@ -56,32 +56,4 @@ private bool AreEqual(Person? actual, Person? expected) && AreEqual(actual.Parent, expected.Parent); } } - - public class TsarRegistry - { - public static Person GetCurrentTsar() - { - return new Person("Ivan IV The Terrible", 54, 170, 70, - new Person("Vasili III of Russia", 28, 170, 60, null)); - } - } - - public class Person - { - public static int IdCounter = 0; - public int Age, Height, Weight; - public string Name; - public Person? Parent; - public int Id; - - public Person(string name, int age, int height, int weight, Person? parent) - { - Id = IdCounter++; - Name = name; - Age = age; - Height = height; - Weight = weight; - Parent = parent; - } - } } \ No newline at end of file From f0d9880856f4b01f9b34dece7afcee8c7f52873d Mon Sep 17 00:00:00 2001 From: tripples25 <92451706+tripples25@users.noreply.github.com> Date: Wed, 29 Nov 2023 07:28:34 +0500 Subject: [PATCH 5/7] Added additional tests in NumberValidatorTests --- .../NumberValidator/NumberValidatorTests.cs | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs index 43e96a60..f356e881 100644 --- a/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs +++ b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs @@ -4,11 +4,10 @@ namespace HomeExercises.NumberValidator { - [TestFixture] public class NumberValidatorTests { - [TestCase(0, 2, true, TestName = "precision is zero")] - [TestCase(-1, 2, true, TestName = "precision is negative")] + [TestCase(0, 2, false, TestName = "precision is zero")] + [TestCase(-1, 2, false, TestName = "precision is negative")] [TestCase(1, -1, false, TestName = "scale is negative")] [TestCase(1, 2, false, TestName = "scale is greater than precision")] [TestCase(1, 1, false, TestName = "scale is equals precision")] @@ -18,16 +17,39 @@ public void Constructor_Fails_OnIncorrectArguments(int precision, int scale, boo a.Should().Throw(); } - [TestCase(1, 0, true, TestName = "with all arguments")] - public void Constructor_Success_OnCorrectArguments(int precision, int scale, bool onlyPositive) + [Test] + public void Constructor_Success_WithThreeArguments() { - Action a = () => { new NumberValidator(precision, scale, onlyPositive); }; + Action a = () => { new NumberValidator(1, 0, false); }; a.Should().NotThrow(); } - + + [Test] + public void Constructor_Success_WithTwoArguments() + { + Action a = () => { new NumberValidator(1, 0); }; + a.Should().NotThrow(); + } + + [Test] + public void Constructor_Success_WithOneArgument() + { + Action a = () => { new NumberValidator(1); }; + a.Should().NotThrow(); + } + [TestCase(3, 2, true, null, TestName = "value is null")] [TestCase(3, 2, true, "", TestName = "value is empty")] - [TestCase(3, 2, true, "+1..23", TestName = "value has incorrect format")] + [TestCase(3, 2, true, " ", TestName = "value is space")] + [TestCase(3, 2, true, "+1..23", TestName = "value contains two separators")] + [TestCase(3, 2, true, "++0", TestName = "value contains two signs")] + [TestCase(3, 2, true, "1.2a", TestName = "value contains letters")] + [TestCase(3, 2, true, "+", TestName = "value only contains sign")] + [TestCase(3, 2, true, "0?0", TestName = "value separated by other symbol than dot or comma")] + [TestCase(3, 2, true, " 0", TestName = "value contains spaces before number")] + [TestCase(3, 2, true, "0 ", TestName = "value contains spaces after number")] + [TestCase(3, 2, true, "0.", TestName = "value hasn't contains numbers after separator")] + [TestCase(3, 2, true, ".0", TestName = "value hasn't contains numbers before separator")] [TestCase(17, 2, true, "0.000", TestName = "value's fraction part length is greater than scale")] [TestCase(5, 2, true, "-0.00", TestName = "negative sign when onlyPositive is true")] [TestCase(3, 2, true, "+0.00", TestName = "intPart and fractPart together is greater than precision")] @@ -54,5 +76,4 @@ public void IsValidNumber_ReturnsTrue_OnCorrectArguments(int precision, int scal .BeTrue(); } } - } \ No newline at end of file From 8478ac80a0f74af50bf01414d2951d57dd8baf8b Mon Sep 17 00:00:00 2001 From: tripples25 <92451706+tripples25@users.noreply.github.com> Date: Wed, 29 Nov 2023 23:08:53 +0500 Subject: [PATCH 6/7] Removed unnecessary constructor tests and did refactor in NumberValidatorTests --- .../NumberValidator/NumberValidatorTests.cs | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs index f356e881..e836be39 100644 --- a/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs +++ b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs @@ -6,31 +6,17 @@ namespace HomeExercises.NumberValidator { public class NumberValidatorTests { - [TestCase(0, 2, false, TestName = "precision is zero")] - [TestCase(-1, 2, false, TestName = "precision is negative")] - [TestCase(1, -1, false, TestName = "scale is negative")] - [TestCase(1, 2, false, TestName = "scale is greater than precision")] - [TestCase(1, 1, false, TestName = "scale is equals precision")] - public void Constructor_Fails_OnIncorrectArguments(int precision, int scale, bool onlyPositive) + [TestCase(0, 2, TestName = "precision is zero")] + [TestCase(-1, 2, TestName = "precision is negative")] + [TestCase(1, -1, TestName = "scale is negative")] + [TestCase(1, 2, TestName = "scale is greater than precision")] + [TestCase(1, 1, TestName = "scale is equals precision")] + public void Constructor_Fails_OnIncorrectArguments(int precision, int scale) { - Action a = () => { new NumberValidator(precision, scale, onlyPositive); }; + Action a = () => { new NumberValidator(precision, scale); }; a.Should().Throw(); } - [Test] - public void Constructor_Success_WithThreeArguments() - { - Action a = () => { new NumberValidator(1, 0, false); }; - a.Should().NotThrow(); - } - - [Test] - public void Constructor_Success_WithTwoArguments() - { - Action a = () => { new NumberValidator(1, 0); }; - a.Should().NotThrow(); - } - [Test] public void Constructor_Success_WithOneArgument() { From 6cb0cc9c9f5dcdf24ce3a0981f4fb7e53dbc7346 Mon Sep 17 00:00:00 2001 From: tripples25 <92451706+tripples25@users.noreply.github.com> Date: Wed, 29 Nov 2023 23:32:25 +0500 Subject: [PATCH 7/7] Changed onlyPositive argument in some TestCases in NumberValidatorTests --- .../NumberValidator/NumberValidatorTests.cs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs index e836be39..7e745a4c 100644 --- a/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs +++ b/cs/HomeExercises/NumberValidator/NumberValidatorTests.cs @@ -24,21 +24,21 @@ public void Constructor_Success_WithOneArgument() a.Should().NotThrow(); } - [TestCase(3, 2, true, null, TestName = "value is null")] - [TestCase(3, 2, true, "", TestName = "value is empty")] - [TestCase(3, 2, true, " ", TestName = "value is space")] - [TestCase(3, 2, true, "+1..23", TestName = "value contains two separators")] - [TestCase(3, 2, true, "++0", TestName = "value contains two signs")] - [TestCase(3, 2, true, "1.2a", TestName = "value contains letters")] - [TestCase(3, 2, true, "+", TestName = "value only contains sign")] - [TestCase(3, 2, true, "0?0", TestName = "value separated by other symbol than dot or comma")] - [TestCase(3, 2, true, " 0", TestName = "value contains spaces before number")] - [TestCase(3, 2, true, "0 ", TestName = "value contains spaces after number")] - [TestCase(3, 2, true, "0.", TestName = "value hasn't contains numbers after separator")] - [TestCase(3, 2, true, ".0", TestName = "value hasn't contains numbers before separator")] - [TestCase(17, 2, true, "0.000", TestName = "value's fraction part length is greater than scale")] + [TestCase(3, 2, false, null, TestName = "value is null")] + [TestCase(3, 2, false, "", TestName = "value is empty")] + [TestCase(3, 2, false, " ", TestName = "value is space")] + [TestCase(3, 2, false, "+1..23", TestName = "value contains two separators")] + [TestCase(3, 2, false, "++0", TestName = "value contains two signs")] + [TestCase(3, 2, false, "1.2a", TestName = "value contains letters")] + [TestCase(3, 2, false, "+", TestName = "value only contains sign")] + [TestCase(3, 2, false, "0?0", TestName = "value separated by other symbol than dot or comma")] + [TestCase(3, 2, false, " 0", TestName = "value contains spaces before number")] + [TestCase(3, 2, false, "0 ", TestName = "value contains spaces after number")] + [TestCase(3, 2, false, "0.", TestName = "value hasn't contains numbers after separator")] + [TestCase(3, 2, false, ".0", TestName = "value hasn't contains numbers before separator")] + [TestCase(17, 2, false, "0.000", TestName = "value's fraction part length is greater than scale")] [TestCase(5, 2, true, "-0.00", TestName = "negative sign when onlyPositive is true")] - [TestCase(3, 2, true, "+0.00", TestName = "intPart and fractPart together is greater than precision")] + [TestCase(3, 2, false, "+0.00", TestName = "intPart and fractPart together is greater than precision")] public void IsValidNumber_ReturnsFalse_OnIncorrectArguments(int precision, int scale, bool onlyPositive, string value) { new NumberValidator(precision, scale, onlyPositive)