Add real pricelist test
This commit is contained in:
parent
58f5c5ba4a
commit
0fcc632024
41
RhSolutions.Tests/RealPricelistTest.cs
Normal file
41
RhSolutions.Tests/RealPricelistTest.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using RhSolutions.AddIn;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace RhSolutions.Tests;
|
||||||
|
|
||||||
|
[ExcelTestSettings(OutOfProcess = true)]
|
||||||
|
public class RealPricelistTest : IDisposable
|
||||||
|
{
|
||||||
|
private RhSolutionsAddIn _addIn;
|
||||||
|
private IReader _reader;
|
||||||
|
|
||||||
|
public RealPricelistTest()
|
||||||
|
{
|
||||||
|
_addIn = new();
|
||||||
|
_addIn.AutoOpen();
|
||||||
|
_reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IReader>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\RealTestSpecification.xlsm")]
|
||||||
|
public void CanWrite()
|
||||||
|
{
|
||||||
|
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
||||||
|
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\RealTargetSpecification.xlsx"));
|
||||||
|
var products = _reader.ReadProducts(new[] { sourceSheet });
|
||||||
|
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
||||||
|
_writer.WriteProducts(products);
|
||||||
|
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
||||||
|
targetSheet.Range["A1"].Formula = "=SUM(H:H)";
|
||||||
|
|
||||||
|
Assert.Equal("RealTestSpecification", products.First().Item1);
|
||||||
|
Assert.Equal("RealTargetSpecification.xlsx", Util.Application.ActiveWorkbook.Name);
|
||||||
|
Assert.Equal(1188.0, targetSheet.Range["A1"].Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_addIn.AutoClose();
|
||||||
|
Util.Application.ActiveWindow.Close(SaveChanges: false);
|
||||||
|
}
|
||||||
|
}
|
BIN
RhSolutions.Tests/TestWorkbooks/RealTargetSpecification.xlsx
Normal file
BIN
RhSolutions.Tests/TestWorkbooks/RealTargetSpecification.xlsx
Normal file
Binary file not shown.
BIN
RhSolutions.Tests/TestWorkbooks/RealTestSpecification.xlsm
Normal file
BIN
RhSolutions.Tests/TestWorkbooks/RealTestSpecification.xlsm
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user