aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.Tests
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-03-22 08:36:13 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-03-22 08:36:13 +0300
commit4f448f203471a19a1444555a895f503515ad2fda (patch)
tree301b7df2561d650e4d300d24341342bd77ac7f3e /RhSolutions.Tests
parent6484cac4f025bd84f7ffa2b2030d729dafe09d3d (diff)
Add basic test
Diffstat (limited to 'RhSolutions.Tests')
-rw-r--r--RhSolutions.Tests/RhSolutions.Tests.csproj14
-rw-r--r--RhSolutions.Tests/Tests.cs38
-rw-r--r--RhSolutions.Tests/Usings.cs3
3 files changed, 55 insertions, 0 deletions
diff --git a/RhSolutions.Tests/RhSolutions.Tests.csproj b/RhSolutions.Tests/RhSolutions.Tests.csproj
new file mode 100644
index 0000000..d6ec3d7
--- /dev/null
+++ b/RhSolutions.Tests/RhSolutions.Tests.csproj
@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net6.0-windows</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ <OutputType>Library</OutputType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="ExcelDna.Testing" Version="1.6.0" />
+ </ItemGroup>
+
+</Project>
diff --git a/RhSolutions.Tests/Tests.cs b/RhSolutions.Tests/Tests.cs
new file mode 100644
index 0000000..3d1e988
--- /dev/null
+++ b/RhSolutions.Tests/Tests.cs
@@ -0,0 +1,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);
+ }
+ }
+} \ No newline at end of file
diff --git a/RhSolutions.Tests/Usings.cs b/RhSolutions.Tests/Usings.cs
new file mode 100644
index 0000000..ef40d98
--- /dev/null
+++ b/RhSolutions.Tests/Usings.cs
@@ -0,0 +1,3 @@
+global using Xunit;
+global using Microsoft.Office.Interop.Excel;
+global using ExcelDna.Testing;