RhSolutions-AddIn/RhSolutions.Tests/CanFillSleeves.cs

50 lines
1.7 KiB
C#
Raw Permalink Normal View History

2023-06-21 07:24:47 +03:00
using RhSolutions.AddIn;
namespace RhSolutions.Tests;
[ExcelTestSettings(OutOfProcess = true)]
public class CanFillSleeves : IDisposable
{
private RhSolutionsAddIn _addIn;
2023-11-02 23:07:06 +03:00
private IFittingsCalculator _calculator;
2023-06-21 07:24:47 +03:00
private IReader _reader;
private IWriter _writer;
private Worksheet _worksheet;
public CanFillSleeves()
{
2023-12-09 23:04:49 +03:00
Environment.SetEnvironmentVariable("ISTESTING", "true");
2023-06-21 07:24:47 +03:00
_addIn = new();
_addIn.AutoOpen();
_calculator = new SleevesCalculator();
_reader = new ExcelReader(Util.Application, RhSolutionsAddIn.Configuration);
_writer = new CurrentPriceWriter(Util.Application, RhSolutionsAddIn.Configuration);
_worksheet = Util.Workbook.Worksheets[1];
}
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationSleeves.xlsx")]
public void CanCalculateSleeves()
{
var products = _reader.ReadProducts(new[] { _worksheet });
2023-11-02 23:07:06 +03:00
var sleeves = _calculator.Calculate(products.First().Item2);
2023-06-21 07:24:47 +03:00
_writer.WriteProducts(sleeves);
2024-05-25 15:15:17 +03:00
Assert.Equal(22, _worksheet.Range["E2"].Value);
Assert.Equal(12, _worksheet.Range["E3"].Value);
Assert.Equal(5, _worksheet.Range["E4"].Value);
Assert.Equal(6, _worksheet.Range["E5"].Value);
Assert.Equal(3, _worksheet.Range["E6"].Value);
2023-06-21 07:24:47 +03:00
Assert.Equal(3, _worksheet.Range["E7"].Value);
2024-05-25 15:15:17 +03:00
Assert.Equal(2, _worksheet.Range["E8"].Value);
Assert.Equal(2, _worksheet.Range["E9"].Value);
Assert.Equal(1, _worksheet.Range["E10"].Value);
Assert.Equal(3, _worksheet.Range["E11"].Value);
Assert.Equal(4, _worksheet.Range["E12"].Value);
2023-06-21 07:24:47 +03:00
}
public void Dispose()
{
_addIn.AutoClose();
}
}