From 7b6f2fedf1080c0ea96f4975f82700db3e12d783 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Tue, 14 Jan 2025 05:59:55 +0000 Subject: Add devcontainers --- RhSolutions.SkuParser.Tests/ExcelParserTests.cs | 96 ++++++++++++------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'RhSolutions.SkuParser.Tests/ExcelParserTests.cs') diff --git a/RhSolutions.SkuParser.Tests/ExcelParserTests.cs b/RhSolutions.SkuParser.Tests/ExcelParserTests.cs index 83e95c1..60e1e7b 100644 --- a/RhSolutions.SkuParser.Tests/ExcelParserTests.cs +++ b/RhSolutions.SkuParser.Tests/ExcelParserTests.cs @@ -1,48 +1,48 @@ -using RhSolutions.SkuParser.Services; - -namespace RhSolutions.SkuParser.Tests; - -public class ExcelParserTests -{ - private static readonly List _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}, - }; - - [TestCase("simple.xlsx")] - [TestCase("simpleWithNames.xlsx")] - [TestCase("withHeader.xlsx")] - [TestCase("withHeaderAndGarbage.xlsx")] - [TestCase("twoTables.xlsx")] - [TestCase("rhSolutionsBsTable.xlsx")] - [TestCase("simpleWithFormulas.xlsx")] - public void XlsxTests(string filename) - { - var mockFile = FormFileUtil.GetMockFormFile(filename); - var parser = new ExcelParser(); - var actual = parser.ParseProducts(mockFile.Object); - Assert.That(actual.Count, Is.EqualTo(_expected.Count())); - CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(ProductQuantity)); - CollectionAssert.AreEqual(_expected, actual); - } - - [TestCase("simple.csv")] - public void CsvTests(string filename) - { - var mockFile = FormFileUtil.GetMockFormFile(filename); - var parser = new CsvParser(); - var actual = parser.ParseProducts(mockFile.Object); - Assert.That(actual.Count, Is.EqualTo(_expected.Count())); - CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(ProductQuantity)); - CollectionAssert.AreEqual(_expected, actual); - } -} +using RhSolutions.SkuParser.Services; + +namespace RhSolutions.SkuParser.Tests; + +public class ExcelParserTests +{ + private static readonly List _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}, + }; + + [TestCase("simple.xlsx")] + [TestCase("simpleWithNames.xlsx")] + [TestCase("withHeader.xlsx")] + [TestCase("withHeaderAndGarbage.xlsx")] + [TestCase("twoTables.xlsx")] + [TestCase("rhSolutionsBsTable.xlsx")] + [TestCase("simpleWithFormulas.xlsx")] + public void XlsxTests(string filename) + { + var mockFile = FormFileUtil.GetMockFormFile(filename); + var parser = new ExcelParser(); + var actual = parser.ParseProducts(mockFile.Object); + Assert.That(actual.Count, Is.EqualTo(_expected.Count())); + CollectionAssert.AllItemsAreInstancesOfType(actual, typeof(ProductQuantity)); + CollectionAssert.AreEqual(_expected, actual); + } + + [TestCase("simple.csv")] + public void CsvTests(string filename) + { + var mockFile = FormFileUtil.GetMockFormFile(filename); + var parser = new CsvParser(); + 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