From a542bfb7f4ceee8b49cf8fcadf64ffb72cc97da5 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Tue, 14 Jan 2025 14:01:01 +0000 Subject: Common Parsing Method --- RhSolutions.SkuParser.Tests/ExcelParserTests.cs | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'RhSolutions.SkuParser.Tests') diff --git a/RhSolutions.SkuParser.Tests/ExcelParserTests.cs b/RhSolutions.SkuParser.Tests/ExcelParserTests.cs index 60e1e7b..781ea56 100644 --- a/RhSolutions.SkuParser.Tests/ExcelParserTests.cs +++ b/RhSolutions.SkuParser.Tests/ExcelParserTests.cs @@ -4,18 +4,18 @@ namespace RhSolutions.SkuParser.Tests; public class ExcelParserTests { - private static readonly List _expected = new() + private static readonly Dictionary _expected = new() { - new ProductQuantity() {Product= new Product() {Sku = "11303703100"}, Quantity = 2129.5}, - new ProductQuantity() {Product= new Product() {Sku = "11303803100"}, Quantity = 503}, - new ProductQuantity() {Product= new Product() {Sku = "11303903050"}, Quantity = 52}, - new ProductQuantity() {Product= new Product() {Sku = "11080011001"}, Quantity = 2154}, - new ProductQuantity() {Product= new Product() {Sku = "11080021001"}, Quantity = 134}, - new ProductQuantity() {Product= new Product() {Sku = "11080031001"}, Quantity = 6}, - new ProductQuantity() {Product= new Product() {Sku = "11080311001"}, Quantity = 462}, - new ProductQuantity() {Product= new Product() {Sku = "11080611001"}, Quantity = 38}, - new ProductQuantity() {Product= new Product() {Sku = "11080811001"}, Quantity = 24}, - new ProductQuantity() {Product= new Product() {Sku = "11080831001"}, Quantity = 2}, + [new Product() {Sku = "11303703100"}] = 2129.5, + [new Product() {Sku = "11303803100"}] = 503, + [new Product() {Sku = "11303903050"}] = 52, + [new Product() {Sku = "11080011001"}] = 2154, + [new Product() {Sku = "11080021001"}] = 134, + [new Product() {Sku = "11080031001"}] = 6, + [new Product() {Sku = "11080311001"}] = 462, + [new Product() {Sku = "11080611001"}] = 38, + [new Product() {Sku = "11080811001"}] = 24, + [new Product() {Sku = "11080831001"}] = 2, }; [TestCase("simple.xlsx")] @@ -28,10 +28,9 @@ public class ExcelParserTests public void XlsxTests(string filename) { var mockFile = FormFileUtil.GetMockFormFile(filename); - var parser = new ExcelParser(); + var parser = new CommonExcelParser(); var actual = parser.ParseProducts(mockFile.Object); Assert.That(actual.Count, Is.EqualTo(_expected.Count())); - CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(ProductQuantity)); CollectionAssert.AreEqual(_expected, actual); } @@ -39,10 +38,9 @@ public class ExcelParserTests public void CsvTests(string filename) { var mockFile = FormFileUtil.GetMockFormFile(filename); - var parser = new CsvParser(); + var parser = new CommonCsvParser(); var actual = parser.ParseProducts(mockFile.Object); Assert.That(actual.Count, Is.EqualTo(_expected.Count())); - CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(ProductQuantity)); CollectionAssert.AreEqual(_expected, actual); } } -- cgit v1.2.3