2023-05-21 15:47:09 +03:00
|
|
|
|
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();
|
2023-05-23 07:01:33 +03:00
|
|
|
|
_reader = new ExcelReader(Util.Application, RhSolutionsAddIn.Configuration);
|
2023-05-21 15:47:09 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\RealTestSpecification.xlsm")]
|
|
|
|
|
public void CanWrite()
|
|
|
|
|
{
|
|
|
|
|
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
2023-07-26 17:17:09 +03:00
|
|
|
|
sourceSheet.Validate();
|
2023-05-21 15:47:09 +03:00
|
|
|
|
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\RealTargetSpecification.xlsx"));
|
|
|
|
|
var products = _reader.ReadProducts(new[] { sourceSheet });
|
2023-06-20 07:25:44 +03:00
|
|
|
|
var _writer = new NewPriceWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
2023-05-21 15:47:09 +03:00
|
|
|
|
_writer.WriteProducts(products);
|
|
|
|
|
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
2023-07-26 17:17:09 +03:00
|
|
|
|
targetSheet.Validate();
|
2023-05-21 15:47:09 +03:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|