blob: 3d1e988cf7114193c7fadc98499cac3ae97ea966 (
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
|
namespace RhSolutions.Tests
{
[ExcelTestSettings(AddIn = @"..\..\..\..\RhSolutions.AddIn\bin\Debug\net6.0-windows\RhSolutions-AddIn")]
public class CalculationTests : IDisposable
{
Workbook _testWorkbook;
public CalculationTests()
{
// Get hold of the Excel Application object and create a workbook
_testWorkbook = Util.Application.Workbooks.Add();
}
public void Dispose()
{
// Clean up our workbook without saving changes
_testWorkbook.Close(SaveChanges: false);
}
[ExcelFact]
public void NumbersAddCorrectly()
{
// We'll just do our test on the first sheet
var ws = _testWorkbook.Sheets[1];
// Write two numbers to the active sheet, and a formula that adds them, together
ws.Range["A1"].Value = 2.0;
ws.Range["A2"].Value = 3.0;
ws.Range["A3"].Formula = "= A1 + A2";
// Read back the value from the cell with the formula
var result = ws.Range["A3"].Value;
// Check that we have the expected result
Assert.Equal(5.0, result);
}
}
}
|