aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerghei Cebotari <serghei@cebotari.ru>2023-11-12 14:57:43 +0300
committerSerghei Cebotari <serghei@cebotari.ru>2023-11-12 14:57:43 +0300
commit02d0b21a5896ea3323511240652ba8c5fd9671c5 (patch)
treeb7ba4c1d14ff7baa0b3ff620354d6dd6b0c3ba62
parent9fd1fd8266a304a2e5c5adf522ae0320a6960c19 (diff)
Add couplings calculator test
-rw-r--r--RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs4
-rw-r--r--RhSolutions.Tests/CanFillCouplings.cs41
-rw-r--r--RhSolutions.Tests/TestWorkbooks/TestSpecificationCouplings.xlsxbin0 -> 358588 bytes
3 files changed, 43 insertions, 2 deletions
diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs
index 38cea15..dcb0f7d 100644
--- a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs
+++ b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs
@@ -72,8 +72,8 @@ public sealed class RhSolutionsAddIn : IExcelAddIn
public void AutoClose()
{
- EventsUtil.Uninitialize();
-
+ EventsUtil.Uninitialize();
+
bool isTesting = Environment.GetEnvironmentVariable("ISTESTING") switch
{
"true" => true,
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
new file mode 100644
index 0000000..0acdf22
--- /dev/null
+++ b/RhSolutions.Tests/TestWorkbooks/TestSpecificationCouplings.xlsx
Binary files differ