From 4f448f203471a19a1444555a895f503515ad2fda Mon Sep 17 00:00:00 2001 From: Sergey Chebotar Date: Wed, 22 Mar 2023 08:36:13 +0300 Subject: [PATCH] Add basic test --- {src => RhSolutions.AddIn}/AddIn/Functions.cs | 0 .../AddIn/RhSolutionsAddIn.cs | 0 .../Controllers/CombineTool.cs | 0 .../Controllers/ConvertTool.cs | 0 .../Controllers/ExportTool.cs | 0 .../Controllers/MergeTool.cs | 0 .../Controllers/RibbonController.cs | 0 .../Controllers/ToolBase.cs | 0 {src => RhSolutions.AddIn}/Models/Dialog.cs | 0 .../Models/PriceListBase.cs | 0 .../Models/PriceListHeaders.cs | 0 {src => RhSolutions.AddIn}/Models/Product.cs | 0 .../Models/ProgressBar.cs | 0 .../Models/ResultBar.cs | 0 .../Models/SourcePriceList.cs | 0 .../Models/StatusbarBase.cs | 0 .../Models/TargetPriceList.cs | 0 .../Models/WorksheetExtensions.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../Properties/ExcelDna.Build.props | 0 .../Properties/launchSettings.json | 0 .../RhSolutions-AddIn.dna | 0 .../RhSolutions.AddIn.csproj | 5 ++- .../Services/EventsUtil.cs | 0 .../Services/RegistryUtil.cs | 0 .../Services/RhDatabaseClient.cs | 0 {src => RhSolutions.AddIn}/app.config | 0 RhSolutions.Tests/RhSolutions.Tests.csproj | 14 +++++++ RhSolutions.Tests/Tests.cs | 38 +++++++++++++++++++ RhSolutions.Tests/Usings.cs | 3 ++ RhSolutions.sln | 8 +++- 31 files changed, 65 insertions(+), 3 deletions(-) rename {src => RhSolutions.AddIn}/AddIn/Functions.cs (100%) rename {src => RhSolutions.AddIn}/AddIn/RhSolutionsAddIn.cs (100%) rename {src => RhSolutions.AddIn}/Controllers/CombineTool.cs (100%) rename {src => RhSolutions.AddIn}/Controllers/ConvertTool.cs (100%) rename {src => RhSolutions.AddIn}/Controllers/ExportTool.cs (100%) rename {src => RhSolutions.AddIn}/Controllers/MergeTool.cs (100%) rename {src => RhSolutions.AddIn}/Controllers/RibbonController.cs (100%) rename {src => RhSolutions.AddIn}/Controllers/ToolBase.cs (100%) rename {src => RhSolutions.AddIn}/Models/Dialog.cs (100%) rename {src => RhSolutions.AddIn}/Models/PriceListBase.cs (100%) rename {src => RhSolutions.AddIn}/Models/PriceListHeaders.cs (100%) rename {src => RhSolutions.AddIn}/Models/Product.cs (100%) rename {src => RhSolutions.AddIn}/Models/ProgressBar.cs (100%) rename {src => RhSolutions.AddIn}/Models/ResultBar.cs (100%) rename {src => RhSolutions.AddIn}/Models/SourcePriceList.cs (100%) rename {src => RhSolutions.AddIn}/Models/StatusbarBase.cs (100%) rename {src => RhSolutions.AddIn}/Models/TargetPriceList.cs (100%) rename {src => RhSolutions.AddIn}/Models/WorksheetExtensions.cs (100%) rename {src => RhSolutions.AddIn}/Properties/AssemblyInfo.cs (100%) rename {src => RhSolutions.AddIn}/Properties/ExcelDna.Build.props (100%) rename {src => RhSolutions.AddIn}/Properties/launchSettings.json (100%) rename {src => RhSolutions.AddIn}/RhSolutions-AddIn.dna (100%) rename src/RhSolutions.csproj => RhSolutions.AddIn/RhSolutions.AddIn.csproj (81%) rename {src => RhSolutions.AddIn}/Services/EventsUtil.cs (100%) rename {src => RhSolutions.AddIn}/Services/RegistryUtil.cs (100%) rename {src => RhSolutions.AddIn}/Services/RhDatabaseClient.cs (100%) rename {src => RhSolutions.AddIn}/app.config (100%) create mode 100644 RhSolutions.Tests/RhSolutions.Tests.csproj create mode 100644 RhSolutions.Tests/Tests.cs create mode 100644 RhSolutions.Tests/Usings.cs diff --git a/src/AddIn/Functions.cs b/RhSolutions.AddIn/AddIn/Functions.cs similarity index 100% rename from src/AddIn/Functions.cs rename to RhSolutions.AddIn/AddIn/Functions.cs diff --git a/src/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs similarity index 100% rename from src/AddIn/RhSolutionsAddIn.cs rename to RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs diff --git a/src/Controllers/CombineTool.cs b/RhSolutions.AddIn/Controllers/CombineTool.cs similarity index 100% rename from src/Controllers/CombineTool.cs rename to RhSolutions.AddIn/Controllers/CombineTool.cs diff --git a/src/Controllers/ConvertTool.cs b/RhSolutions.AddIn/Controllers/ConvertTool.cs similarity index 100% rename from src/Controllers/ConvertTool.cs rename to RhSolutions.AddIn/Controllers/ConvertTool.cs diff --git a/src/Controllers/ExportTool.cs b/RhSolutions.AddIn/Controllers/ExportTool.cs similarity index 100% rename from src/Controllers/ExportTool.cs rename to RhSolutions.AddIn/Controllers/ExportTool.cs diff --git a/src/Controllers/MergeTool.cs b/RhSolutions.AddIn/Controllers/MergeTool.cs similarity index 100% rename from src/Controllers/MergeTool.cs rename to RhSolutions.AddIn/Controllers/MergeTool.cs diff --git a/src/Controllers/RibbonController.cs b/RhSolutions.AddIn/Controllers/RibbonController.cs similarity index 100% rename from src/Controllers/RibbonController.cs rename to RhSolutions.AddIn/Controllers/RibbonController.cs diff --git a/src/Controllers/ToolBase.cs b/RhSolutions.AddIn/Controllers/ToolBase.cs similarity index 100% rename from src/Controllers/ToolBase.cs rename to RhSolutions.AddIn/Controllers/ToolBase.cs diff --git a/src/Models/Dialog.cs b/RhSolutions.AddIn/Models/Dialog.cs similarity index 100% rename from src/Models/Dialog.cs rename to RhSolutions.AddIn/Models/Dialog.cs diff --git a/src/Models/PriceListBase.cs b/RhSolutions.AddIn/Models/PriceListBase.cs similarity index 100% rename from src/Models/PriceListBase.cs rename to RhSolutions.AddIn/Models/PriceListBase.cs diff --git a/src/Models/PriceListHeaders.cs b/RhSolutions.AddIn/Models/PriceListHeaders.cs similarity index 100% rename from src/Models/PriceListHeaders.cs rename to RhSolutions.AddIn/Models/PriceListHeaders.cs diff --git a/src/Models/Product.cs b/RhSolutions.AddIn/Models/Product.cs similarity index 100% rename from src/Models/Product.cs rename to RhSolutions.AddIn/Models/Product.cs diff --git a/src/Models/ProgressBar.cs b/RhSolutions.AddIn/Models/ProgressBar.cs similarity index 100% rename from src/Models/ProgressBar.cs rename to RhSolutions.AddIn/Models/ProgressBar.cs diff --git a/src/Models/ResultBar.cs b/RhSolutions.AddIn/Models/ResultBar.cs similarity index 100% rename from src/Models/ResultBar.cs rename to RhSolutions.AddIn/Models/ResultBar.cs diff --git a/src/Models/SourcePriceList.cs b/RhSolutions.AddIn/Models/SourcePriceList.cs similarity index 100% rename from src/Models/SourcePriceList.cs rename to RhSolutions.AddIn/Models/SourcePriceList.cs diff --git a/src/Models/StatusbarBase.cs b/RhSolutions.AddIn/Models/StatusbarBase.cs similarity index 100% rename from src/Models/StatusbarBase.cs rename to RhSolutions.AddIn/Models/StatusbarBase.cs diff --git a/src/Models/TargetPriceList.cs b/RhSolutions.AddIn/Models/TargetPriceList.cs similarity index 100% rename from src/Models/TargetPriceList.cs rename to RhSolutions.AddIn/Models/TargetPriceList.cs diff --git a/src/Models/WorksheetExtensions.cs b/RhSolutions.AddIn/Models/WorksheetExtensions.cs similarity index 100% rename from src/Models/WorksheetExtensions.cs rename to RhSolutions.AddIn/Models/WorksheetExtensions.cs diff --git a/src/Properties/AssemblyInfo.cs b/RhSolutions.AddIn/Properties/AssemblyInfo.cs similarity index 100% rename from src/Properties/AssemblyInfo.cs rename to RhSolutions.AddIn/Properties/AssemblyInfo.cs diff --git a/src/Properties/ExcelDna.Build.props b/RhSolutions.AddIn/Properties/ExcelDna.Build.props similarity index 100% rename from src/Properties/ExcelDna.Build.props rename to RhSolutions.AddIn/Properties/ExcelDna.Build.props diff --git a/src/Properties/launchSettings.json b/RhSolutions.AddIn/Properties/launchSettings.json similarity index 100% rename from src/Properties/launchSettings.json rename to RhSolutions.AddIn/Properties/launchSettings.json diff --git a/src/RhSolutions-AddIn.dna b/RhSolutions.AddIn/RhSolutions-AddIn.dna similarity index 100% rename from src/RhSolutions-AddIn.dna rename to RhSolutions.AddIn/RhSolutions-AddIn.dna diff --git a/src/RhSolutions.csproj b/RhSolutions.AddIn/RhSolutions.AddIn.csproj similarity index 81% rename from src/RhSolutions.csproj rename to RhSolutions.AddIn/RhSolutions.AddIn.csproj index 60182f6..022dccc 100644 --- a/src/RhSolutions.csproj +++ b/RhSolutions.AddIn/RhSolutions.AddIn.csproj @@ -13,10 +13,11 @@ + - + - + diff --git a/src/Services/EventsUtil.cs b/RhSolutions.AddIn/Services/EventsUtil.cs similarity index 100% rename from src/Services/EventsUtil.cs rename to RhSolutions.AddIn/Services/EventsUtil.cs diff --git a/src/Services/RegistryUtil.cs b/RhSolutions.AddIn/Services/RegistryUtil.cs similarity index 100% rename from src/Services/RegistryUtil.cs rename to RhSolutions.AddIn/Services/RegistryUtil.cs diff --git a/src/Services/RhDatabaseClient.cs b/RhSolutions.AddIn/Services/RhDatabaseClient.cs similarity index 100% rename from src/Services/RhDatabaseClient.cs rename to RhSolutions.AddIn/Services/RhDatabaseClient.cs diff --git a/src/app.config b/RhSolutions.AddIn/app.config similarity index 100% rename from src/app.config rename to RhSolutions.AddIn/app.config 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 @@ + + + + net6.0-windows + enable + enable + Library + + + + + + + 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; diff --git a/RhSolutions.sln b/RhSolutions.sln index e1850b4..8d94b9b 100644 --- a/RhSolutions.sln +++ b/RhSolutions.sln @@ -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