Add basic test

This commit is contained in:
Sergey Chebotar 2023-03-22 08:36:13 +03:00
parent 6484cac4f0
commit 4f448f2034
31 changed files with 65 additions and 3 deletions

View File

@ -13,10 +13,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ExcelDna.AddIn" Version="1.6.0" />
<PackageReference Include="ExcelDna.Integration" Version="1.6.0" />
<PackageReference Include="ExcelDna.IntelliSense" Version="1.6.0" />
<PackageReference Include="ExcelDna.Interop" Version="15.0.0" />
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="RhSolutions.Sku" Version="0.1.1" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

View File

@ -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>

View File

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

View File

@ -0,0 +1,3 @@
global using Xunit;
global using Microsoft.Office.Interop.Excel;
global using ExcelDna.Testing;

View File

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions", "src\RhSolutions.csproj", "{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RhSolutions.AddIn", "RhSolutions.AddIn\RhSolutions.AddIn.csproj", "{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RhSolutions.Tests", "RhSolutions.Tests\RhSolutions.Tests.csproj", "{6EECCDDB-741C-404A-874F-BB8656265162}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -15,6 +17,10 @@ Global
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18A2FF67-0E46-4A86-B872-29F2B3F23ADF}.Release|Any CPU.Build.0 = Release|Any CPU
{6EECCDDB-741C-404A-874F-BB8656265162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EECCDDB-741C-404A-874F-BB8656265162}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EECCDDB-741C-404A-874F-BB8656265162}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EECCDDB-741C-404A-874F-BB8656265162}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE