RhSolutions-AddIn/RhSolutions.Tests/CanFillCouplings.cs

42 lines
1.1 KiB
C#
Raw Permalink Normal View History

2023-11-12 14:57:43 +03:00
using RhSolutions.AddIn;
namespace RhSolutions.Tests;
[ExcelTestSettings(OutOfProcess = true)]
public class CanFillCouplings : IDisposable
{
2024-10-31 23:31:14 +03:00
private RhSolutionsAddIn _addIn;
private IFittingsCalculator _calculator;
private IReader _reader;
private IWriter _writer;
private Worksheet _worksheet;
2023-11-12 14:57:43 +03:00
2024-10-31 23:31:14 +03:00
public CanFillCouplings()
{
Environment.SetEnvironmentVariable("ISTESTING", "true");
_addIn = new();
_addIn.AutoOpen();
_calculator = new CouplingsCalculator();
_reader = new ExcelReader(Util.Application, RhSolutionsAddIn.Configuration);
_writer = new CurrentPriceWriter(Util.Application, RhSolutionsAddIn.Configuration);
_worksheet = Util.Workbook.Worksheets[1];
}
2023-11-12 14:57:43 +03:00
2024-10-31 23:31:14 +03:00
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationCouplings.xlsx")]
public void CanCalculateSleeves()
{
var products = _reader.ReadProducts(new[] { _worksheet });
var couplings = _calculator.Calculate(products.First().Item2);
_writer.WriteProducts(couplings);
for (int i = 2; i < 14; i++)
{
Assert.Equal(_worksheet.Range[$"F{i}"].Value, _worksheet.Range[$"E{i}"].Value);
}
}
2023-11-12 14:57:43 +03:00
2024-10-31 23:31:14 +03:00
public void Dispose()
{
_addIn.AutoClose();
}
2023-11-12 14:57:43 +03:00
}