aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.Tests/CanFillCouplings.cs
blob: 2c6c0bb58aafe52aa37e0574589c6a9f876b3ea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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()
	{
		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];
	}

	[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);
		}
	}

	public void Dispose()
	{
		_addIn.AutoClose();
	}
}