aboutsummaryrefslogtreecommitdiff
path: root/RhSolutions.Tests
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-03-23 17:13:48 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-03-23 17:13:48 +0300
commit3c93c978d4745650c19e5b750329121913e2c418 (patch)
treeed1436cc685f5c6d390d4652406990c2e73cd267 /RhSolutions.Tests
parent2cef4d1d9f95ee358b61963dff1ce71e97e9a03c (diff)
Add Workbook check tests
Diffstat (limited to 'RhSolutions.Tests')
-rw-r--r--RhSolutions.Tests/CalculationTests.cs30
-rw-r--r--RhSolutions.Tests/RhSolutions.Tests.csproj35
-rw-r--r--RhSolutions.Tests/RhSolutionsCheckTest.cs46
-rw-r--r--RhSolutions.Tests/TestWorkbooks/EmptyTestTable.xlsxbin0 -> 9236 bytes
-rw-r--r--RhSolutions.Tests/TestWorkbooks/EmptyWorkbook.xlsxbin0 -> 8413 bytes
-rw-r--r--RhSolutions.Tests/Usings.cs2
-rw-r--r--RhSolutions.Tests/WorkbookCheckTests.cs16
7 files changed, 50 insertions, 79 deletions
diff --git a/RhSolutions.Tests/CalculationTests.cs b/RhSolutions.Tests/CalculationTests.cs
deleted file mode 100644
index d6c54c2..0000000
--- a/RhSolutions.Tests/CalculationTests.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-namespace RhSolutions.Tests;
-
-public class CalculationTests : IDisposable
-{
- private Workbook workbook;
-
- public CalculationTests()
- {
- workbook = Util.Application.Workbooks.Add();
- }
-
- public void Dispose()
- {
- workbook.Close(SaveChanges: false);
- }
-
- [ExcelFact]
- public void NumbersAddCorrectly()
- {
- var ws = workbook.Sheets[1];
-
- ws.Range["A1"].Value = 2.0;
- ws.Range["A2"].Value = 3.0;
- ws.Range["A3"].Formula = "= A1 + A2";
-
- var result = ws.Range["A3"].Value;
-
- Assert.Equal(5.0, result);
- }
-} \ No newline at end of file
diff --git a/RhSolutions.Tests/RhSolutions.Tests.csproj b/RhSolutions.Tests/RhSolutions.Tests.csproj
index d6ec3d7..aeb9c9e 100644
--- a/RhSolutions.Tests/RhSolutions.Tests.csproj
+++ b/RhSolutions.Tests/RhSolutions.Tests.csproj
@@ -1,14 +1,29 @@
<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>
+ <PropertyGroup>
+ <TargetFramework>net472</TargetFramework>
+ <LangVersion>10</LangVersion>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ <OutputType>Library</OutputType>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
+ <PackageReference Include="ExcelDna.Testing" Version="1.6.0" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\RhSolutions.AddIn\RhSolutions.AddIn.csproj" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <None Update="TestWorkbooks\EmptyTestTable.xlsx">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Update="TestWorkbooks\EmptyWorkbook.xlsx">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
</Project>
diff --git a/RhSolutions.Tests/RhSolutionsCheckTest.cs b/RhSolutions.Tests/RhSolutionsCheckTest.cs
index a3a6460..b4d93dc 100644
--- a/RhSolutions.Tests/RhSolutionsCheckTest.cs
+++ b/RhSolutions.Tests/RhSolutionsCheckTest.cs
@@ -1,30 +1,30 @@
-namespace RhSolutions.Tests;
-
-[ExcelTestSettings(AddIn = @"..\..\..\..\RhSolutions.AddIn\bin\Debug\net6.0-windows\RhSolutions-AddIn")]
-public class RhSolutionsCheckTest : IDisposable
+namespace RhSolutions.Tests
{
- private Workbook workbook;
-
- public RhSolutionsCheckTest()
- {
- workbook = Util.Application.Workbooks.Add();
- }
-
- [ExcelFact]
- public void RhSolutionsFunctionWorks()
+ [ExcelTestSettings(AddIn = @"..\..\..\..\RhSolutions.AddIn\bin\Debug\net472\RhSolutions-AddIn", OutOfProcess = true)]
+ public class WorkbookCheck : IDisposable
{
- var ws = workbook.Sheets[1];
-
- ws.Range["A1"].Formula = "=RHSOLUTIONS(\"гильза 16\")";
- Util.Application.CalculateFull();
+ public WorkbookCheck()
+ {
+ Util.Application.Workbooks.Add();
+ }
- var result = ws.Range["A1"].Value;
+ [ExcelFact(Workbook = @"TestWorkbooks\EmptyTestTable.xlsx")]
+ public void WorksheetIsCorrect()
+ {
+ Worksheet worksheet= Util.Workbook.Sheets[1];
+ Assert.True(worksheet.IsRehauSource());
+ }
- Assert.Equal("Загрузка...", result);
- }
+ [ExcelFact(Workbook = @"TestWorkbooks\EmptyWorkbook.xlsx")]
+ public void EmptyWorkbookIsNotCorrect()
+ {
+ Worksheet worksheet = Util.Workbook.Sheets[1];
+ Assert.False(worksheet.IsRehauSource());
+ }
- public void Dispose()
- {
- Util.Application.ActiveWorkbook.Close(SaveChanges: false);
+ public void Dispose()
+ {
+ Util.Application.ActiveWorkbook.Close(SaveChanges: false);
+ }
}
}
diff --git a/RhSolutions.Tests/TestWorkbooks/EmptyTestTable.xlsx b/RhSolutions.Tests/TestWorkbooks/EmptyTestTable.xlsx
new file mode 100644
index 0000000..1df17d6
--- /dev/null
+++ b/RhSolutions.Tests/TestWorkbooks/EmptyTestTable.xlsx
Binary files differ
diff --git a/RhSolutions.Tests/TestWorkbooks/EmptyWorkbook.xlsx b/RhSolutions.Tests/TestWorkbooks/EmptyWorkbook.xlsx
new file mode 100644
index 0000000..16f63fd
--- /dev/null
+++ b/RhSolutions.Tests/TestWorkbooks/EmptyWorkbook.xlsx
Binary files differ
diff --git a/RhSolutions.Tests/Usings.cs b/RhSolutions.Tests/Usings.cs
index ef40d98..74130ca 100644
--- a/RhSolutions.Tests/Usings.cs
+++ b/RhSolutions.Tests/Usings.cs
@@ -1,3 +1,5 @@
global using Xunit;
global using Microsoft.Office.Interop.Excel;
global using ExcelDna.Testing;
+global using RhSolutions.Models;
+global using RhSolutions.Services;
diff --git a/RhSolutions.Tests/WorkbookCheckTests.cs b/RhSolutions.Tests/WorkbookCheckTests.cs
deleted file mode 100644
index 997134b..0000000
--- a/RhSolutions.Tests/WorkbookCheckTests.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-//namespace RhSolutions.Tests;
-
-//[ExcelTestSettings(AddIn = @"..\..\..\..\RhSolutions.AddIn\bin\Debug\net6.0-windows\RhSolutions-AddIn")]
-//public class WorkbookCheckTests : IDisposable
-//{
-// [ExcelFact(Workbook = @".\Workbooks\EmptyTestTable.xlsx")]
-// public void WorksheetIsCorrect()
-// {
-// Assert.True(true);
-// }
-
-// public void Dispose()
-// {
-// Util.Application.ActiveWorkbook.Close(SaveChanges: false);
-// }
-//} \ No newline at end of file