Add write products test
This commit is contained in:
parent
58a45df8cf
commit
49efdad03e
39
RhSolutions.Tests/CanWriteProducts.cs
Normal file
39
RhSolutions.Tests/CanWriteProducts.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using RhSolutions.AddIn;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace RhSolutions.Tests;
|
||||||
|
|
||||||
|
[ExcelTestSettings(OutOfProcess = true)]
|
||||||
|
public class CanWriteProducts : IDisposable
|
||||||
|
{
|
||||||
|
private RhSolutionsAddIn _addIn;
|
||||||
|
private IReader _reader;
|
||||||
|
|
||||||
|
public CanWriteProducts()
|
||||||
|
{
|
||||||
|
_addIn = new();
|
||||||
|
_addIn.AutoOpen();
|
||||||
|
_reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IReader>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecificaion.xlsx")]
|
||||||
|
public void CanWrite()
|
||||||
|
{
|
||||||
|
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
||||||
|
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecifictaion.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(products.First().Item2.Count(), targetProducts.First().Item2.Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_addIn.AutoClose();
|
||||||
|
Util.Application.ActiveWindow.Close(SaveChanges: false);
|
||||||
|
}
|
||||||
|
}
|
BIN
RhSolutions.Tests/TestWorkbooks/TargetSpecifictaion.xlsx
Normal file
BIN
RhSolutions.Tests/TestWorkbooks/TargetSpecifictaion.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user