From 9183834d729da9b164f2a1ab2824e02ec2a75b37 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Tue, 28 Jan 2025 16:11:56 -0800 Subject: [PATCH] Refactor MSI code tests to use Xunit assertions --- .../msi/SplunkCustomActions/test/GlobalUsings.cs | 1 - .../test/MultiStringEnvironmentTests.cs | 14 +++++++------- .../test/SplunkCustomActionsTests.csproj | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packaging/msi/SplunkCustomActions/test/GlobalUsings.cs b/packaging/msi/SplunkCustomActions/test/GlobalUsings.cs index 91743bbbbb..c802f4480b 100644 --- a/packaging/msi/SplunkCustomActions/test/GlobalUsings.cs +++ b/packaging/msi/SplunkCustomActions/test/GlobalUsings.cs @@ -1,2 +1 @@ global using Xunit; -global using FluentAssertions; diff --git a/packaging/msi/SplunkCustomActions/test/MultiStringEnvironmentTests.cs b/packaging/msi/SplunkCustomActions/test/MultiStringEnvironmentTests.cs index 244972d229..40a73f6eec 100644 --- a/packaging/msi/SplunkCustomActions/test/MultiStringEnvironmentTests.cs +++ b/packaging/msi/SplunkCustomActions/test/MultiStringEnvironmentTests.cs @@ -35,7 +35,7 @@ public void GetEnvironmentValue() using (var multiStringEnvironment = new MultiStringEnvironment(RegistryHive.CurrentUser, TestSubKey, TestValueName)) { var actualEnvironment = multiStringEnvironment.GetEnvironmentValue(); - actualEnvironment.Should().BeEquivalentTo(initialEnvironment); + Assert.Equal(initialEnvironment, actualEnvironment); } } finally @@ -73,7 +73,8 @@ public void AddingOptionalConfigurations() "key3=value3" }; - Registry.GetValue(TestKey, TestValueName, Array.Empty()).Should().BeEquivalentTo(expectedEnvironment); + var actualEnvironment = Registry.GetValue(TestKey, TestValueName, Array.Empty()); + Assert.Equal(expectedEnvironment, actualEnvironment); } finally { @@ -84,11 +85,10 @@ public void AddingOptionalConfigurations() [Fact] public void DefaultConstructorShouldFail() { - Action action = () => new MultiStringEnvironment(); - action - .Should() - .Throw() - .WithMessage("Failed to open the registry sub key: SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector"); + var invalidOperationException = Assert.Throws(() => new MultiStringEnvironment()); + Assert.Equal( + @"Failed to open the registry sub key: SYSTEM\CurrentControlSet\Services\splunk-otel-collector", + invalidOperationException.Message); } private void DeleteTestSubKey() diff --git a/packaging/msi/SplunkCustomActions/test/SplunkCustomActionsTests.csproj b/packaging/msi/SplunkCustomActions/test/SplunkCustomActionsTests.csproj index ff1d6c38f3..affedbc705 100644 --- a/packaging/msi/SplunkCustomActions/test/SplunkCustomActionsTests.csproj +++ b/packaging/msi/SplunkCustomActions/test/SplunkCustomActionsTests.csproj @@ -11,7 +11,6 @@ -