diff options
Diffstat (limited to 'RhSolutions.SkuParser.Tests/ProductTests.cs')
-rw-r--r-- | RhSolutions.SkuParser.Tests/ProductTests.cs | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/RhSolutions.SkuParser.Tests/ProductTests.cs b/RhSolutions.SkuParser.Tests/ProductTests.cs index 12f0944..ee7396d 100644 --- a/RhSolutions.SkuParser.Tests/ProductTests.cs +++ b/RhSolutions.SkuParser.Tests/ProductTests.cs @@ -1,75 +1,75 @@ -namespace RhSolutions.SkuParser.Tests; - -public class ProductTests -{ - [TestCase("12222221001")] - [TestCase("12222223001")] - [TestCase("160001-001")] - public void SimpleParse(string value) - { - Assert.True(Product.TryParse(value, out _)); - } - - [TestCase("string 12222221001")] - [TestCase("12222223001 string")] - [TestCase("string 160001-001")] - [TestCase("160001-001 string ")] - [TestCase("11096641001 Трубка РЕХАУ из. нерж. стали для подкл. радиатора, Г-образная 16/250")] - public void AdvancedParse(string value) - { - Assert.True(Product.TryParse(value, out _)); - } - - [TestCase("11600011001")] - [TestCase("160001-001")] - public void ProductIsCorrect(string value) - { - if (Product.TryParse(value, out Product? product)) - { - Assert.That(product!.Sku, Is.EqualTo("11600011001")); - } - else - { - Assert.Fail($"Parsing failed on {value}"); - } - } - - [TestCase("1222222001")] - [TestCase("12222225001")] - public void NotParses(string value) - { - Assert.False(Product.TryParse(value, out _)); - } - - [Test] - public void ProductEquality() - { - string value = "12222223001"; - Product.TryParse(value, out Product? first); - Product.TryParse(value, out Product? second); - if (first == null || second == null) - { - Assert.Fail($"Parsing failed on {value}"); - } - else - { - Assert.True(first.Equals(second)); - } - } - - [Test] - public void HashTest() - { - string value = "12222223001"; - HashSet<Product> set = new(); - if (Product.TryParse(value, out var product)) - { - set.Add(product!); - } - else - { - Assert.Fail($"Parsing failed on {value}"); - } - Assert.True(set.Contains(product!)); - } +namespace RhSolutions.SkuParser.Tests;
+
+public class ProductTests
+{
+ [TestCase("12222221001")]
+ [TestCase("12222223001")]
+ [TestCase("160001-001")]
+ public void SimpleParse(string value)
+ {
+ Assert.True(Product.TryParse(value, out _));
+ }
+
+ [TestCase("string 12222221001")]
+ [TestCase("12222223001 string")]
+ [TestCase("string 160001-001")]
+ [TestCase("160001-001 string ")]
+ [TestCase("11096641001 Трубка РЕХАУ из. нерж. стали для подкл. радиатора, Г-образная 16/250")]
+ public void AdvancedParse(string value)
+ {
+ Assert.True(Product.TryParse(value, out _));
+ }
+
+ [TestCase("11600011001")]
+ [TestCase("160001-001")]
+ public void ProductIsCorrect(string value)
+ {
+ if (Product.TryParse(value, out Product? product))
+ {
+ Assert.That(product!.Sku, Is.EqualTo("11600011001"));
+ }
+ else
+ {
+ Assert.Fail($"Parsing failed on {value}");
+ }
+ }
+
+ [TestCase("1222222001")]
+ [TestCase("12222225001")]
+ public void NotParses(string value)
+ {
+ Assert.False(Product.TryParse(value, out _));
+ }
+
+ [Test]
+ public void ProductEquality()
+ {
+ string value = "12222223001";
+ Product.TryParse(value, out Product? first);
+ Product.TryParse(value, out Product? second);
+ if (first == null || second == null)
+ {
+ Assert.Fail($"Parsing failed on {value}");
+ }
+ else
+ {
+ Assert.True(first.Equals(second));
+ }
+ }
+
+ [Test]
+ public void HashTest()
+ {
+ string value = "12222223001";
+ HashSet<Product> set = new();
+ if (Product.TryParse(value, out var product))
+ {
+ set.Add(product!);
+ }
+ else
+ {
+ Assert.Fail($"Parsing failed on {value}");
+ }
+ Assert.True(set.Contains(product!));
+ }
}
\ No newline at end of file |