From a8c192848de3cf6728326677cb047202366566c5 Mon Sep 17 00:00:00 2001 From: Serghei Cebotari Date: Sat, 9 Dec 2023 23:04:49 +0300 Subject: [PATCH] Fixt testing environment variable --- RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs | 20 ++++--------------- .../Properties/launchSettings.json | 5 ++++- RhSolutions.Tests/.runsettings | 8 -------- RhSolutions.Tests/CanDoGuess.cs | 1 + RhSolutions.Tests/CanFillCouplings.cs | 1 + RhSolutions.Tests/CanFillSleeves.cs | 1 + RhSolutions.Tests/CanReadProducts.cs | 1 + RhSolutions.Tests/CanWriteProducts.cs | 1 + RhSolutions.Tests/RealPricelistTest.cs | 1 + RhSolutions.Tests/WorkbookValidationTests.cs | 1 + 10 files changed, 15 insertions(+), 25 deletions(-) delete mode 100644 RhSolutions.Tests/.runsettings diff --git a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs index f2bdd6f..a5ff466 100644 --- a/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs +++ b/RhSolutions.AddIn/AddIn/RhSolutionsAddIn.cs @@ -55,15 +55,9 @@ public sealed class RhSolutionsAddIn : IExcelAddIn EventsUtil.Initialize(); - bool isTesting = Environment.GetEnvironmentVariable("ISTESTING") switch + if (Environment.GetEnvironmentVariable("ISTESTING") == "false") { - "true" => true, - "false" => false, - _ => false - }; - if (!isTesting) - { - //IntelliSenseServer.Install(); + IntelliSenseServer.Install(); } ServicePointManager.SecurityProtocol = @@ -74,15 +68,9 @@ public sealed class RhSolutionsAddIn : IExcelAddIn { EventsUtil.Uninitialize(); - bool isTesting = Environment.GetEnvironmentVariable("ISTESTING") switch + if (Environment.GetEnvironmentVariable("ISTESTING") == "false") { - "true" => true, - "false" => false, - _ => false - }; - if (!isTesting) - { - //IntelliSenseServer.Uninstall(); + IntelliSenseServer.Uninstall(); } } } diff --git a/RhSolutions.AddIn/Properties/launchSettings.json b/RhSolutions.AddIn/Properties/launchSettings.json index c36dbc3..7f7ccfe 100644 --- a/RhSolutions.AddIn/Properties/launchSettings.json +++ b/RhSolutions.AddIn/Properties/launchSettings.json @@ -3,7 +3,10 @@ "Excel": { "commandName": "Executable", "executablePath": "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE", - "commandLineArgs": "RhSolutions-AddIn64.xll" + "commandLineArgs": "RhSolutions-AddIn64.xll", + "environmentVariables": { + "ISTESTING": "false" + } } } } \ No newline at end of file diff --git a/RhSolutions.Tests/.runsettings b/RhSolutions.Tests/.runsettings deleted file mode 100644 index 5f93304..0000000 --- a/RhSolutions.Tests/.runsettings +++ /dev/null @@ -1,8 +0,0 @@ - - - - - true - - - \ No newline at end of file diff --git a/RhSolutions.Tests/CanDoGuess.cs b/RhSolutions.Tests/CanDoGuess.cs index a43c92e..c187a16 100644 --- a/RhSolutions.Tests/CanDoGuess.cs +++ b/RhSolutions.Tests/CanDoGuess.cs @@ -13,6 +13,7 @@ public class CanDoGuess : IDisposable public CanDoGuess() { + Environment.SetEnvironmentVariable("ISTESTING", "true"); _addIn = new(); _addIn.AutoOpen(); _guessReader = new GuessReader(Util.Application); diff --git a/RhSolutions.Tests/CanFillCouplings.cs b/RhSolutions.Tests/CanFillCouplings.cs index 48e4ee8..5a57c32 100644 --- a/RhSolutions.Tests/CanFillCouplings.cs +++ b/RhSolutions.Tests/CanFillCouplings.cs @@ -13,6 +13,7 @@ public class CanFillCouplings : IDisposable public CanFillCouplings() { + Environment.SetEnvironmentVariable("ISTESTING", "true"); _addIn = new(); _addIn.AutoOpen(); _calculator = new CouplingsCalculator(); diff --git a/RhSolutions.Tests/CanFillSleeves.cs b/RhSolutions.Tests/CanFillSleeves.cs index ca00407..3b8adfa 100644 --- a/RhSolutions.Tests/CanFillSleeves.cs +++ b/RhSolutions.Tests/CanFillSleeves.cs @@ -13,6 +13,7 @@ public class CanFillSleeves : IDisposable public CanFillSleeves() { + Environment.SetEnvironmentVariable("ISTESTING", "true"); _addIn = new(); _addIn.AutoOpen(); _calculator = new SleevesCalculator(); diff --git a/RhSolutions.Tests/CanReadProducts.cs b/RhSolutions.Tests/CanReadProducts.cs index e796da0..84de589 100644 --- a/RhSolutions.Tests/CanReadProducts.cs +++ b/RhSolutions.Tests/CanReadProducts.cs @@ -12,6 +12,7 @@ public class CanReadProducts : IDisposable public CanReadProducts() { + Environment.SetEnvironmentVariable("ISTESTING", "true"); _addIn = new(); _testWorkbook = Util.Application.Workbooks.Add(); _addIn.AutoOpen(); diff --git a/RhSolutions.Tests/CanWriteProducts.cs b/RhSolutions.Tests/CanWriteProducts.cs index 50ce662..e6676cd 100644 --- a/RhSolutions.Tests/CanWriteProducts.cs +++ b/RhSolutions.Tests/CanWriteProducts.cs @@ -12,6 +12,7 @@ public class CanWriteProducts : IDisposable public CanWriteProducts() { + Environment.SetEnvironmentVariable("ISTESTING", "true"); _addIn = new(); _addIn.AutoOpen(); _reader = new ExcelReader(Util.Application, RhSolutionsAddIn.Configuration); diff --git a/RhSolutions.Tests/RealPricelistTest.cs b/RhSolutions.Tests/RealPricelistTest.cs index 9ff3a25..284c328 100644 --- a/RhSolutions.Tests/RealPricelistTest.cs +++ b/RhSolutions.Tests/RealPricelistTest.cs @@ -12,6 +12,7 @@ public class RealPricelistTest : IDisposable public RealPricelistTest() { + Environment.SetEnvironmentVariable("ISTESTING", "true"); _addIn = new(); _addIn.AutoOpen(); _reader = new ExcelReader(Util.Application, RhSolutionsAddIn.Configuration); diff --git a/RhSolutions.Tests/WorkbookValidationTests.cs b/RhSolutions.Tests/WorkbookValidationTests.cs index f5b338a..bd2af8c 100644 --- a/RhSolutions.Tests/WorkbookValidationTests.cs +++ b/RhSolutions.Tests/WorkbookValidationTests.cs @@ -10,6 +10,7 @@ public class WorkbookValidationTests : IDisposable public WorkbookValidationTests() { + Environment.SetEnvironmentVariable("ISTESTING", "true"); _addIn = new RhSolutionsAddIn(); _addIn.AutoOpen(); Util.Application.Workbooks.Add();