diff options
author | Serghei Cebotari <serghei@cebotari.ru> | 2023-11-12 14:57:43 +0300 |
---|---|---|
committer | Serghei Cebotari <serghei@cebotari.ru> | 2023-11-12 14:57:43 +0300 |
commit | 02d0b21a5896ea3323511240652ba8c5fd9671c5 (patch) | |
tree | b7ba4c1d14ff7baa0b3ff620354d6dd6b0c3ba62 /RhSolutions.Tests | |
parent | 9fd1fd8266a304a2e5c5adf522ae0320a6960c19 (diff) |
Add couplings calculator test
Diffstat (limited to 'RhSolutions.Tests')
-rw-r--r-- | RhSolutions.Tests/CanFillCouplings.cs | 41 | ||||
-rw-r--r-- | RhSolutions.Tests/TestWorkbooks/TestSpecificationCouplings.xlsx | bin | 0 -> 358588 bytes |
2 files changed, 41 insertions, 0 deletions
diff --git a/RhSolutions.Tests/CanFillCouplings.cs b/RhSolutions.Tests/CanFillCouplings.cs new file mode 100644 index 0000000..48e4ee8 --- /dev/null +++ b/RhSolutions.Tests/CanFillCouplings.cs @@ -0,0 +1,41 @@ +using RhSolutions.AddIn; + +namespace RhSolutions.Tests; + +[ExcelTestSettings(OutOfProcess = true)] +public class CanFillCouplings : IDisposable +{ + private RhSolutionsAddIn _addIn; + private IFittingsCalculator _calculator; + private IReader _reader; + private IWriter _writer; + private Worksheet _worksheet; + + public CanFillCouplings() + { + _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]; + } + + [ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationCouplings.xlsx")] + public void CanCalculateSleeves() + { + var products = _reader.ReadProducts(new[] { _worksheet }); + var couplings = _calculator.Calculate(products.First().Item2); + _writer.WriteProducts(couplings); + + Assert.Equal(7, _worksheet.Range["E2"].Value); + Assert.Equal(1, _worksheet.Range["E3"].Value); + Assert.Equal(1, _worksheet.Range["E5"].Value); + Assert.Equal(1, _worksheet.Range["E7"].Value); + } + + public void Dispose() + { + _addIn.AutoClose(); + } +} diff --git a/RhSolutions.Tests/TestWorkbooks/TestSpecificationCouplings.xlsx b/RhSolutions.Tests/TestWorkbooks/TestSpecificationCouplings.xlsx Binary files differnew file mode 100644 index 0000000..0acdf22 --- /dev/null +++ b/RhSolutions.Tests/TestWorkbooks/TestSpecificationCouplings.xlsx |