Add Magic reader test
This commit is contained in:
parent
5720d2ede0
commit
7a7cdaab58
44
RhSolutions.Tests/CanDoMagic.cs
Normal file
44
RhSolutions.Tests/CanDoMagic.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using RhSolutions.AddIn;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace RhSolutions.Tests;
|
||||||
|
|
||||||
|
[ExcelTestSettings(OutOfProcess = true)]
|
||||||
|
public class CanDoMagic : IDisposable
|
||||||
|
{
|
||||||
|
private RhSolutionsAddIn _addIn;
|
||||||
|
private ReaderFactory _readerFactory;
|
||||||
|
private IReader _reader;
|
||||||
|
|
||||||
|
public CanDoMagic()
|
||||||
|
{
|
||||||
|
_addIn = new();
|
||||||
|
_addIn.AutoOpen();
|
||||||
|
_readerFactory = RhSolutionsAddIn.ServiceProvider.GetRequiredService<ReaderFactory>();
|
||||||
|
_reader = _readerFactory.GetReader("Magic");
|
||||||
|
}
|
||||||
|
|
||||||
|
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationMagic.xlsx")]
|
||||||
|
public void CanWrite()
|
||||||
|
{
|
||||||
|
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
||||||
|
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationMagic.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("TestSpecificationMagic", products.First().Item1);
|
||||||
|
Assert.Equal("TargetSpecificationMagic", targetProducts.First().Item1);
|
||||||
|
Assert.Equal(products.First().Item2.Count(), targetProducts.First().Item2.Count());
|
||||||
|
Assert.Equal(products.First().Item2.Values.Sum(), targetProducts.First().Item2.Values.Sum());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_addIn.AutoClose();
|
||||||
|
Util.Application.ActiveWindow.Close(SaveChanges: false);
|
||||||
|
}
|
||||||
|
}
|
BIN
RhSolutions.Tests/TestWorkbooks/TargetSpecificationMagic.xlsx
Normal file
BIN
RhSolutions.Tests/TestWorkbooks/TargetSpecificationMagic.xlsx
Normal file
Binary file not shown.
BIN
RhSolutions.Tests/TestWorkbooks/TestSpecificationMagic.xlsx
Normal file
BIN
RhSolutions.Tests/TestWorkbooks/TestSpecificationMagic.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user