Skip to content

Commit

Permalink
Refactor MSI code tests to use Xunit assertions (#5845)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanotti authored Jan 29, 2025
1 parent 9476567 commit da778dd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion packaging/msi/SplunkCustomActions/test/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
global using Xunit;
global using FluentAssertions;
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,7 +73,8 @@ public void AddingOptionalConfigurations()
"key3=value3"
};

Registry.GetValue(TestKey, TestValueName, Array.Empty<string>()).Should().BeEquivalentTo(expectedEnvironment);
var actualEnvironment = Registry.GetValue(TestKey, TestValueName, Array.Empty<string>());
Assert.Equal(expectedEnvironment, actualEnvironment);
}
finally
{
Expand All @@ -84,11 +85,10 @@ public void AddingOptionalConfigurations()
[Fact]
public void DefaultConstructorShouldFail()
{
Action action = () => new MultiStringEnvironment();
action
.Should()
.Throw<InvalidOperationException>()
.WithMessage("Failed to open the registry sub key: SYSTEM\\CurrentControlSet\\Services\\splunk-otel-collector");
var invalidOperationException = Assert.Throws<InvalidOperationException>(() => new MultiStringEnvironment());
Assert.Equal(
@"Failed to open the registry sub key: SYSTEM\CurrentControlSet\Services\splunk-otel-collector",
invalidOperationException.Message);
}

private void DeleteTestSubKey()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="8.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
Expand Down

0 comments on commit da778dd

Please sign in to comment.