Add Fill Sleeves Tests
This commit is contained in:
parent
6a5038246f
commit
9f4823378f
44
RhSolutions.Tests/CanFillSleeves.cs
Normal file
44
RhSolutions.Tests/CanFillSleeves.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using RhSolutions.AddIn;
|
||||||
|
|
||||||
|
namespace RhSolutions.Tests;
|
||||||
|
|
||||||
|
[ExcelTestSettings(OutOfProcess = true)]
|
||||||
|
public class CanFillSleeves : IDisposable
|
||||||
|
{
|
||||||
|
private RhSolutionsAddIn _addIn;
|
||||||
|
private ISleevesCalculator _calculator;
|
||||||
|
private IReader _reader;
|
||||||
|
private IWriter _writer;
|
||||||
|
private Worksheet _worksheet;
|
||||||
|
|
||||||
|
public CanFillSleeves()
|
||||||
|
{
|
||||||
|
_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 });
|
||||||
|
var sleeves = _calculator.CalculateSleeves(products.First().Item2);
|
||||||
|
_writer.WriteProducts(sleeves);
|
||||||
|
|
||||||
|
Assert.Equal(25, _worksheet.Range["E2"].Value);
|
||||||
|
Assert.Equal(15, _worksheet.Range["E3"].Value);
|
||||||
|
Assert.Equal(7, _worksheet.Range["E4"].Value);
|
||||||
|
Assert.Equal(8, _worksheet.Range["E5"].Value);
|
||||||
|
Assert.Equal(1, _worksheet.Range["E6"].Value);
|
||||||
|
Assert.Equal(3, _worksheet.Range["E7"].Value);
|
||||||
|
Assert.Equal(4, _worksheet.Range["E8"].Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_addIn.AutoClose();
|
||||||
|
}
|
||||||
|
}
|
BIN
RhSolutions.Tests/TestWorkbooks/TestSpecificationSleeves.xlsx
Normal file
BIN
RhSolutions.Tests/TestWorkbooks/TestSpecificationSleeves.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user