diff options
author | Serghei Cebotari <serghei@cebotari.ru> | 2025-04-28 10:50:34 +0300 |
---|---|---|
committer | Serghei Cebotari <serghei@cebotari.ru> | 2025-04-28 10:50:34 +0300 |
commit | 52718a90922b569350e36baee5d4d3c3e5723fed (patch) | |
tree | ddf8c90a6666f43ea549a73c5e31fd6974e7243c | |
parent | 4902d3361008579949fbc7734b5ed25ed2063691 (diff) |
Add unit tests for BsExcelParser to validate product parsing
-rw-r--r-- | RhSolutions.SkuParser.Tests/BsExcelParserTests.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/RhSolutions.SkuParser.Tests/BsExcelParserTests.cs b/RhSolutions.SkuParser.Tests/BsExcelParserTests.cs new file mode 100644 index 0000000..c69088a --- /dev/null +++ b/RhSolutions.SkuParser.Tests/BsExcelParserTests.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Configuration; +using RhSolutions.SkuParser.Api.Services; +using RhSolutions.SkuParser.Services; + +namespace RhSolutions.SkuParser.Tests; + +public class BsExcelParserTests +{ + [TestCase("rhSolutionsBsTable.xlsx")] + public void BsTests(string filename) + { + var mockFile = FormFileUtil.GetMockFormFile(filename); + + var configuration = new ConfigurationBuilder() + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: false) + .Build(); + + var parser = new BsExcelParser(configuration); + var actual = parser.ParseProducts(mockFile.Object); + var expected = new Dictionary<Product, double>() + { + [new Product() { Sku = "11303703100", Name = "Унив.труба РЕХАУ FLEX 16x2,2, бухта 100м", Price = 2.45M, ProductLine = ProductLine.RAUTITAN }] = 2129.5, + [new Product() { Sku = "11303803100", Name = "Унив.труба РЕХАУ FLEX 20x2,8, бухта 100м", Price = 3.66M, ProductLine = ProductLine.RAUTITAN }] = 503, + [new Product() { Sku = "11303903050", Name = "Унив.труба РЕХАУ FLEX 25x3,5, бухта 50м", Price = 5.68M, ProductLine = ProductLine.RAUTITAN }] = 52, + [new Product() { Sku = "11080011001", Name = "Монтажная гильза 16 LX", Price = 1.42M, ProductLine = ProductLine.RAUTITAN }] = 2154, + [new Product() { Sku = "11080021001", Name = "Монтажная гильза 20 LX", Price = 1.45M, ProductLine = ProductLine.RAUTITAN }] = 134, + [new Product() { Sku = "11080031001", Name = "Монтажная гильза 25 LX", Price = 2.48M, ProductLine = ProductLine.RAUTITAN }] = 6, + [new Product() { Sku = "11080311001", Name = "Тройник равнопроходный 16-16-16 MX", Price = 6.84M, ProductLine = ProductLine.RAUTITAN }] = 462, + [new Product() { Sku = "11080611001", Name = "Тройник с уменьшенным боковым проходом 20-16-20 MX", Price = 8.14M, ProductLine = ProductLine.RAUTITAN }] = 38, + [new Product() { Sku = "11080811001", Name = "Тройник с уменьшенным боковым и торцевым проходами 20-16-16 MX", Price = 8.33M, ProductLine = ProductLine.RAUTITAN }] = 24, + [new Product() { Sku = "11080831001", Name = "Тройник с уменьшенным боковым и торцевым проходами 25-16-20 MX", Price = 10.64M, ProductLine = ProductLine.RAUTITAN }] = 2, + }; + + Assert.That(actual.Count, Is.EqualTo(expected.Count())); + CollectionAssert.AreEqual(expected, actual); + } +}
\ No newline at end of file |