Add multiple product lines test

This commit is contained in:
Sergey Chebotar 2023-05-21 10:24:16 +03:00
parent 1d64c8839d
commit 06b397cebf
3 changed files with 17 additions and 1 deletions

View File

@ -17,7 +17,7 @@ public class CanWriteProducts : IDisposable
_reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IReader>(); _reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IReader>();
} }
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecification.xlsx")] [ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecification.xlsx")]
public void CanWriteSingle() public void CanWriteSingle()
{ {
Worksheet sourceSheet = Util.Workbook.Worksheets[1]; Worksheet sourceSheet = Util.Workbook.Worksheets[1];
@ -34,6 +34,22 @@ public class CanWriteProducts : IDisposable
Assert.Equal(products.First().Item2.Values.Sum(), targetProducts.First().Item2.Values.Sum()); Assert.Equal(products.First().Item2.Values.Sum(), targetProducts.First().Item2.Values.Sum());
} }
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationMultipleProductLines.xlsx")]
public void CanWriteMultipleProductLines()
{
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationMultipleProductLines.xlsx"));
var products = _reader.ReadProducts(new[] { sourceSheet });
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
_writer.WriteProducts(products);
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
var targetProducts = _reader.ReadProducts(new[] { targetSheet });
Assert.Equal("TestSpecificationMultipleProductLines", products.First().Item1);
Assert.Equal("TargetSpecificationMultipleProductLines", targetProducts.First().Item1);
Assert.True(Enumerable.SequenceEqual(products.First().Item2, targetProducts.First().Item2));
}
public void Dispose() public void Dispose()
{ {
_addIn.AutoClose(); _addIn.AutoClose();