From 88fe3251ea407ed7df2b7f277b0de1b9093cb9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Tue, 14 Jan 2025 14:41:56 +0100 Subject: [PATCH] Drop FluentAssertions --- test/Directory.Build.props | 1 - .../ContinuousProfilerTests.cs | 44 ++++++++----------- .../Helpers/ResourceExpectorExtensions.cs | 7 ++- .../Helpers/TestHelper.cs | 5 +-- .../SelfContainedTests.cs | 9 ++-- .../ServerTimingHeaderTests.cs | 24 +++++----- .../SmokeTests.cs | 9 ++-- ...utoInstrumentation.IntegrationTests.csproj | 3 +- .../ExporterTests.cs | 2 +- .../LoggerTests.cs | 8 ++-- .../MetricsTests.cs | 17 +++---- .../ResourceConfiguratorTests.cs | 17 ++++--- .../SdkLimitOptionsConfiguratorTests.cs | 40 +++++++---------- .../SettingsTests.cs | 19 +++----- .../TracesTests.cs | 14 +++--- .../Usings.cs | 1 - .../VersionTests.cs | 8 +--- 17 files changed, 89 insertions(+), 139 deletions(-) diff --git a/test/Directory.Build.props b/test/Directory.Build.props index 8a0b3baa..b361f2a3 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -12,7 +12,6 @@ - diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ContinuousProfilerTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ContinuousProfilerTests.cs index a4f2bdf1..ec29294b 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ContinuousProfilerTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ContinuousProfilerTests.cs @@ -19,8 +19,6 @@ #if NET using System.IO.Compression; -using FluentAssertions; -using FluentAssertions.Execution; using Google.Protobuf.Collections; using OpenTelemetry.Proto.Collector.Logs.V1; using OpenTelemetry.Proto.Common.V1; @@ -49,7 +47,7 @@ public async Task SubmitAllocationSamples() RunTestApplication(); var logsData = logsCollector.GetAllLogs(); - logsData.Length.Should().BeGreaterOrEqualTo(expected: 1); + Assert.True(logsData.Length > 0); await DumpLogRecords(logsData); @@ -68,14 +66,11 @@ public async Task SubmitAllocationSamples() profiles.Add(profile); } - using (new AssertionScope()) - { - AllShouldHaveBasicAttributes(logRecords, ConstantValuedAttributes("allocation")); - ProfilesContainAllocationValue(profiles); - RecordsContainFrameCountAttribute(logRecords); - ResourceContainsExpectedAttributes(dataResourceLog.Resource); - HasNameAndVersionSet(instrumentationLibraryLogs.Scope); - } + AllShouldHaveBasicAttributes(logRecords, ConstantValuedAttributes("allocation")); + ProfilesContainAllocationValue(profiles); + RecordsContainFrameCountAttribute(logRecords); + ResourceContainsExpectedAttributes(dataResourceLog.Resource); + HasNameAndVersionSet(instrumentationLibraryLogs.Scope); logRecords.Clear(); } @@ -94,7 +89,7 @@ public async Task SubmitThreadSamples() var logsData = logsCollector.GetAllLogs(); // The application works for 6 seconds with debug logging enabled we expect at least 2 attempts of thread sampling in CI. // On a dev box it is typical to get at least 4 but the CI machines seem slower, using 2 - logsData.Length.Should().BeGreaterOrEqualTo(expected: 2); + Assert.True(logsData.Length > 2); await DumpLogRecords(logsData); @@ -118,14 +113,11 @@ public async Task SubmitThreadSamples() containStackTraceForClassHierarchy |= profiles.Any(profile => ContainsStackTrace(profile, expectedStackTrace)); - using (new AssertionScope()) - { - AllShouldHaveBasicAttributes(logRecords, ConstantValuedAttributes("cpu")); - ProfilesDoNotContainAnyValue(profiles); - RecordsContainFrameCountAttribute(logRecords); - ResourceContainsExpectedAttributes(dataResourceLog.Resource); - HasNameAndVersionSet(instrumentationLibraryLogs.Scope); - } + AllShouldHaveBasicAttributes(logRecords, ConstantValuedAttributes("cpu")); + ProfilesDoNotContainAnyValue(profiles); + RecordsContainFrameCountAttribute(logRecords); + ResourceContainsExpectedAttributes(dataResourceLog.Resource); + HasNameAndVersionSet(instrumentationLibraryLogs.Scope); logRecords.Clear(); } @@ -137,7 +129,7 @@ private static void ProfilesContainAllocationValue(List profiles) { foreach (var profile in profiles) { - profile.Samples.All(x => x.Values.Length == 1).Should().BeTrue(); + Assert.All(profile.Samples, x => Assert.Single(x.Values)); } } @@ -145,7 +137,7 @@ private static void ProfilesDoNotContainAnyValue(List profiles) { foreach (var profile in profiles) { - profile.Samples.All(x => x.Values.Length == 0).Should().BeTrue(); + Assert.All(profile.Samples, x => Assert.Empty(x.Values)); } } @@ -153,7 +145,7 @@ private static void RecordsContainFrameCountAttribute(RepeatedField l { foreach (var logRecord in logRecords) { - logRecord.Attributes.Should().Contain(attr => attr.Key == "profiling.data.total.frame.count"); + Assert.Single(logRecord.Attributes, attr => attr.Key == "profiling.data.total.frame.count"); } } @@ -185,7 +177,7 @@ private static void AllShouldHaveBasicAttributes(RepeatedField logRec { foreach (var attribute in attributes) { - logRecord.Attributes.Should().ContainEquivalentOf(attribute); + Assert.Contains(attribute, logRecord.Attributes); } } } @@ -208,8 +200,8 @@ private static void ResourceContainsExpectedAttributes(global::OpenTelemetry.Pro private static void HasNameAndVersionSet(InstrumentationScope instrumentationScope) { - instrumentationScope.Name.Should().Be("otel.profiling"); - instrumentationScope.Version.Should().Be("0.1.0"); + Assert.Equal("otel.profiling", instrumentationScope.Name); + Assert.Equal("0.1.0", instrumentationScope.Version); } private static bool ContainsStackTrace(Profile profile, string expectedStackTrace) diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/ResourceExpectorExtensions.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/ResourceExpectorExtensions.cs index bc4725ca..1f851425 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/ResourceExpectorExtensions.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/ResourceExpectorExtensions.cs @@ -15,7 +15,6 @@ // using System.Reflection; -using FluentAssertions; using OpenTelemetry.Proto.Common.V1; using OpenTelemetry.Proto.Resource.V1; @@ -52,11 +51,11 @@ internal static void AssertProfileResources(Resource resource) foreach (var constantAttribute in constantAttributes) { - resource.Attributes.Should().ContainEquivalentOf(constantAttribute); + Assert.Contains(constantAttribute, resource.Attributes); } // asserting resource attribute without values - resource.Attributes.Should().Contain(value => value.Key == "host.name"); - resource.Attributes.Should().Contain(value => value.Key == "process.pid"); + Assert.Single(resource.Attributes, value => value.Key == "host.name"); + Assert.Single(resource.Attributes, value => value.Key == "process.pid"); } } diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/TestHelper.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/TestHelper.cs index 202b8d93..f34834f4 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/TestHelper.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Helpers/TestHelper.cs @@ -34,7 +34,6 @@ using System.Diagnostics; using System.Reflection; -using FluentAssertions; using Xunit.Abstractions; namespace Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.Helpers; @@ -147,8 +146,8 @@ public void RunTestApplication(TestSettings testSettings = null) Output.WriteLine("Exit Code: " + process.ExitCode); Output.WriteResult(helper); - processTimeout.Should().BeFalse("Test application timed out"); - process.ExitCode.Should().Be(0, "Test application exited with non-zero exit code"); + Assert.False(processTimeout, "Test application timed out"); + Assert.Equal(0, process.ExitCode); } /// diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SelfContainedTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SelfContainedTests.cs index 7bb69a58..24fa88ba 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SelfContainedTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SelfContainedTests.cs @@ -30,7 +30,6 @@ // limitations under the License. // -using FluentAssertions; using Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.Helpers; using Xunit.Abstractions; @@ -50,7 +49,7 @@ public SelfContainedTests(ITestOutputHelper output) // The self-contained app is going to have an extra folder before it: the one // with a RID like "win-x64", "linux-x64", etc. var childrenDirs = Directory.GetDirectories(nonSelfContainedOutputDir); - childrenDirs.Should().ContainSingle(); + Assert.Single(childrenDirs); _selfContainedAppDir = childrenDirs[0]; } @@ -92,7 +91,7 @@ private void RunInstrumentationTarget(string instrumentationTarget) using var process = InstrumentedProcessHelper.Start(instrumentationScriptPath, instrumentationTarget, EnvironmentHelper); using var helper = new ProcessHelper(process); - process.Should().NotBeNull(); + Assert.NotNull(process); bool processTimeout = !process!.WaitForExit((int)Helpers.Timeout.ProcessExit.TotalMilliseconds); if (processTimeout) @@ -104,8 +103,8 @@ private void RunInstrumentationTarget(string instrumentationTarget) Output.WriteLine("Exit Code: " + process.ExitCode); Output.WriteResult(helper); - processTimeout.Should().BeFalse("test application should NOT have timed out"); - process.ExitCode.Should().Be(0, "test application should NOT have non-zero exit code"); + Assert.False(processTimeout, "test application should NOT have timed out"); + Assert.Equal(0, process.ExitCode); } private void RunAndAssertHttpSpans(Action appLauncherAction) diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ServerTimingHeaderTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ServerTimingHeaderTests.cs index d64b54ec..7657b8a7 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ServerTimingHeaderTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/ServerTimingHeaderTests.cs @@ -16,8 +16,6 @@ #if NET -using FluentAssertions; -using FluentAssertions.Execution; using Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.Helpers; using Xunit.Abstractions; @@ -50,7 +48,8 @@ public async Task SubmitRequest(bool isEnabled, bool captureHeaders) { if (captureHeaders) { - return span.Attributes.FirstOrDefault(x => x.Key == "http.request.header.custom-request-test-header")?.Value.StringValue == "Test-Value"; + return span.Attributes.FirstOrDefault(x => x.Key == "http.request.header.custom-request-test-header") + ?.Value.StringValue == "Test-Value"; } return true; @@ -79,18 +78,15 @@ public async Task SubmitRequest(bool isEnabled, bool captureHeaders) Output.WriteResult(helper); - using (new AssertionScope()) + if (isEnabled) { - if (isEnabled) - { - response.Headers.Should().Contain(x => x.Key == "Server-Timing"); - response.Headers.Should().Contain(x => x.Key == "Access-Control-Expose-Headers"); - } - else - { - response.Headers.Should().NotContain(x => x.Key == "Server-Timing"); - response.Headers.Should().NotContain(x => x.Key == "Access-Control-Expose-Headers"); - } + Assert.Single(response.Headers, x => x.Key == "Server-Timing"); + Assert.Single(response.Headers, x => x.Key == "Access-Control-Expose-Headers"); + } + else + { + Assert.DoesNotContain(response.Headers, x => x.Key == "Server-Timing"); + Assert.DoesNotContain(response.Headers, x => x.Key == "Access-Control-Expose-Headers"); } collector.AssertExpectations(); diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SmokeTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SmokeTests.cs index 760ac118..d1c0c211 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SmokeTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/SmokeTests.cs @@ -30,7 +30,6 @@ // limitations under the License. // -using FluentAssertions; using Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.Helpers; using Xunit.Abstractions; @@ -181,7 +180,7 @@ public void ManagedLogsHaveNoSensitiveData() var managedLog = tempLogsDirectory.GetFiles("otel-dotnet-auto-*-Splunk-*.log").Single(); var managedLogContent = File.ReadAllText(managedLog.FullName); - managedLogContent.Should().NotBeNullOrWhiteSpace(); + Assert.False(string.IsNullOrWhiteSpace(managedLogContent)); var environmentVariables = ParseSettingsLog(managedLogContent, "Environment Variables:"); VerifyVariables(environmentVariables); @@ -198,14 +197,14 @@ public void ManagedLogsHaveNoSensitiveData() void VerifyVariables(ICollection> options) { - options.Should().NotBeEmpty(); + Assert.NotEmpty(options); var secretVariables = options .Where(item => secretIdentificators.Any(i => item.Key.Contains(i))) .ToList(); - secretVariables.Should().NotBeEmpty(); - secretVariables.Should().AllSatisfy(secret => secret.Value.Should().Be("")); + Assert.NotEmpty(secretVariables); + Assert.All(secretVariables, secret => Assert.Equal("", secret.Value)); } } diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.csproj b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.csproj index 56a7b4d1..6cac404c 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.csproj +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests/Splunk.OpenTelemetry.AutoInstrumentation.IntegrationTests.csproj @@ -1,4 +1,4 @@ - + @@ -36,7 +36,6 @@ - diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ExporterTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ExporterTests.cs index 8f6b1459..741df059 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ExporterTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ExporterTests.cs @@ -33,7 +33,7 @@ public void ConfigureOtlpOptions_EndpointSpecified() var options = new OtlpExporterOptions(); new Metrics(settings).ConfigureMetricsOptions(options); - options.Endpoint.Should().Be(endpoint); + Assert.StartsWith(endpoint, options.Endpoint.ToString()); Environment.SetEnvironmentVariable("SPLUNK_REALM", null); Environment.SetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT", null); diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/LoggerTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/LoggerTests.cs index c7db12f4..b0cc49b7 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/LoggerTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/LoggerTests.cs @@ -23,15 +23,13 @@ public class LoggerTests [Fact] public void ConstructorDoesNotThrowExceptionWhenReflectionFails() { - var action = () => new Logger(); - action.Should().NotThrow(); + _ = new Logger(); } [Fact] public void ImplementationDoesNotThrowExceptionWhenReflectionFails() { - ILogger logger = new Logger(); - var action = () => logger.Warning("message"); - action.Should().NotThrow(); + var logger = new Logger(); + logger.Warning("message"); } } diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/MetricsTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/MetricsTests.cs index 6648a24b..78233d75 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/MetricsTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/MetricsTests.cs @@ -15,7 +15,6 @@ // using System.Collections.Specialized; -using FluentAssertions.Execution; using OpenTelemetry.Exporter; using Splunk.OpenTelemetry.AutoInstrumentation.Configuration; using Splunk.OpenTelemetry.AutoInstrumentation.Logging; @@ -38,11 +37,8 @@ public void ConfigureOtlpOptions() var options = new OtlpExporterOptions(); new Metrics(settings).ConfigureMetricsOptions(options); - using (new AssertionScope()) - { - options.Endpoint.Should().Be("https://ingest.my-realm.signalfx.com/v2/datapoint/otlp"); - options.Headers.Should().Be("X-Sf-Token=MyToken"); - } + Assert.Equal("https://ingest.my-realm.signalfx.com/v2/datapoint/otlp", options.Endpoint.ToString()); + Assert.Equal("X-Sf-Token=MyToken", options.Headers); } [Theory] @@ -62,12 +58,9 @@ public void WhenRealmIsSetRequireAccessToken(string? accessToken) new Metrics(settings, loggerMock).ConfigureMetricsOptions(options); - using (new AssertionScope()) - { - loggerMock.Received(1).Error(Arg.Any()); + loggerMock.Received(1).Error(Arg.Any()); - options.Endpoint.ToString().Should().NotContain("my-realm"); - options.Headers.Should().BeNull(); - } + Assert.DoesNotContain("my-realm", options.Endpoint.ToString()); + Assert.Null(options.Headers); } } diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ResourceConfiguratorTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ResourceConfiguratorTests.cs index c233485c..075c3fb5 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ResourceConfiguratorTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/ResourceConfiguratorTests.cs @@ -16,7 +16,6 @@ using System.Collections.Specialized; using System.Reflection; -using FluentAssertions.Execution; using OpenTelemetry.Resources; using Splunk.OpenTelemetry.AutoInstrumentation.Configuration; @@ -40,14 +39,14 @@ public void ConfigureSplunkDistributionVersion() var resource = resourceBuilder.Build(); var version = typeof(Plugin).Assembly.GetCustomAttribute()!.InformationalVersion.Split('+')[0]; - using (new AssertionScope()) + + var expected = new Dictionary { - resource.Attributes.Should().BeEquivalentTo(new Dictionary - { - { "splunk.distro.version", version }, - { "telemetry.distro.name", "splunk-otel-dotnet" }, - { "telemetry.distro.version", version } - }); - } + { "splunk.distro.version", version }, + { "telemetry.distro.name", "splunk-otel-dotnet" }, + { "telemetry.distro.version", version } + }; + + Assert.Equivalent(expected, resource.Attributes); } } diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SdkLimitOptionsConfiguratorTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SdkLimitOptionsConfiguratorTests.cs index a9470bcb..44bf4ba3 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SdkLimitOptionsConfiguratorTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SdkLimitOptionsConfiguratorTests.cs @@ -14,8 +14,6 @@ // limitations under the License. // -using FluentAssertions.Execution; - namespace Splunk.OpenTelemetry.AutoInstrumentation.Tests { public class SdkLimitOptionsConfiguratorTests : IDisposable @@ -35,17 +33,14 @@ public void ConfigureEmptyValues() { SdkLimitOptionsConfigurator.Configure(); - using (new AssertionScope()) - { - Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT").Should().Be("12000"); - Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_COUNT_LIMIT").Should().Be("2147483647"); - Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT").Should().BeNullOrEmpty(); - Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT").Should().BeNullOrEmpty(); - Environment.GetEnvironmentVariable("OTEL_SPAN_EVENT_COUNT_LIMIT").Should().Be("2147483647"); - Environment.GetEnvironmentVariable("OTEL_SPAN_LINK_COUNT_LIMIT").Should().Be("1000"); - Environment.GetEnvironmentVariable("OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT").Should().BeNullOrEmpty(); - Environment.GetEnvironmentVariable("OTEL_LINK_ATTRIBUTE_COUNT_LIMIT").Should().BeNullOrEmpty(); - } + Assert.Equal("12000", Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")); + Assert.Equal("2147483647", Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_COUNT_LIMIT")); + Assert.True(string.IsNullOrEmpty(Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT"))); + Assert.True(string.IsNullOrEmpty(Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT"))); + Assert.Equal("2147483647", Environment.GetEnvironmentVariable("OTEL_SPAN_EVENT_COUNT_LIMIT")); + Assert.Equal("1000", Environment.GetEnvironmentVariable("OTEL_SPAN_LINK_COUNT_LIMIT")); + Assert.True(string.IsNullOrEmpty(Environment.GetEnvironmentVariable("OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT"))); + Assert.True(string.IsNullOrEmpty(Environment.GetEnvironmentVariable("OTEL_LINK_ATTRIBUTE_COUNT_LIMIT"))); } [Fact] @@ -62,17 +57,14 @@ public void ConfigurePreservesPreconfiguredValues() SdkLimitOptionsConfigurator.Configure(); - using (new AssertionScope()) - { - Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT").Should().Be("1"); - Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_COUNT_LIMIT").Should().Be("2"); - Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT").Should().Be("3"); - Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT").Should().Be("4"); - Environment.GetEnvironmentVariable("OTEL_SPAN_EVENT_COUNT_LIMIT").Should().Be("5"); - Environment.GetEnvironmentVariable("OTEL_SPAN_LINK_COUNT_LIMIT").Should().Be("6"); - Environment.GetEnvironmentVariable("OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT").Should().Be("7"); - Environment.GetEnvironmentVariable("OTEL_LINK_ATTRIBUTE_COUNT_LIMIT").Should().Be("8"); - } + Assert.Equal("1", Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT")); + Assert.Equal("2", Environment.GetEnvironmentVariable("OTEL_ATTRIBUTE_COUNT_LIMIT")); + Assert.Equal("3", Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT")); + Assert.Equal("4", Environment.GetEnvironmentVariable("OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT")); + Assert.Equal("5", Environment.GetEnvironmentVariable("OTEL_SPAN_EVENT_COUNT_LIMIT")); + Assert.Equal("6", Environment.GetEnvironmentVariable("OTEL_SPAN_LINK_COUNT_LIMIT")); + Assert.Equal("7", Environment.GetEnvironmentVariable("OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT")); + Assert.Equal("8", Environment.GetEnvironmentVariable("OTEL_LINK_ATTRIBUTE_COUNT_LIMIT")); } private static void ClearEnvVars() diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SettingsTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SettingsTests.cs index 5e3bca5e..8eb03db5 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SettingsTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/SettingsTests.cs @@ -14,8 +14,6 @@ // limitations under the License. // -using FluentAssertions.Execution; - namespace Splunk.OpenTelemetry.AutoInstrumentation.Tests { public class SettingsTests : IDisposable @@ -35,18 +33,15 @@ internal void PluginSettings_DefaultValues() { var settings = PluginSettings.FromDefaultSources(); - using (new AssertionScope()) - { - settings.Realm.Should().Be("none"); - settings.AccessToken.Should().BeNull(); - settings.TraceResponseHeaderEnabled.Should().BeTrue(); + Assert.Equal("none", settings.Realm); + Assert.Null(settings.AccessToken); + Assert.True(settings.TraceResponseHeaderEnabled); #if NET - settings.ProfilerLogsEndpoint.Should().Be("http://localhost:4318/v1/logs"); - settings.CpuProfilerEnabled.Should().BeFalse(); - settings.MemoryProfilerEnabled.Should().BeFalse(); - settings.CpuProfilerCallStackInterval.Should().Be(10000u); + Assert.Equal("http://localhost:4318/v1/logs", settings.ProfilerLogsEndpoint.ToString()); + Assert.False(settings.CpuProfilerEnabled); + Assert.False(settings.MemoryProfilerEnabled); + Assert.Equal(10000u, settings.CpuProfilerCallStackInterval); #endif - } } private static void ClearEnvVars() diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/TracesTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/TracesTests.cs index 2a17cf58..30909597 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/TracesTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/TracesTests.cs @@ -15,7 +15,6 @@ // using System.Collections.Specialized; -using FluentAssertions.Execution; using OpenTelemetry.Exporter; using Splunk.OpenTelemetry.AutoInstrumentation.Configuration; using Splunk.OpenTelemetry.AutoInstrumentation.Logging; @@ -38,8 +37,8 @@ public void ConfigureOtlpOptions() var options = new OtlpExporterOptions(); new Traces(settings).ConfigureTracesOptions(options); - options.Endpoint.Should().Be("https://ingest.my-realm.signalfx.com/v2/trace/otlp"); - options.Headers.Should().Be("X-Sf-Token=MyToken"); + Assert.Equal("https://ingest.my-realm.signalfx.com/v2/trace/otlp", options.Endpoint.ToString()); + Assert.Equal("X-Sf-Token=MyToken", options.Headers); } [Theory] @@ -59,12 +58,9 @@ public void WhenRealmIsSetRequireAccessToken(string? accessToken) new Traces(settings, loggerMock).ConfigureTracesOptions(options); - using (new AssertionScope()) - { - loggerMock.Received().Error(Arg.Any()); + loggerMock.Received().Error(Arg.Any()); - options.Endpoint.ToString().Should().NotContain("my-realm"); - options.Headers.Should().BeNull(); - } + Assert.DoesNotContain("my-realm", options.Endpoint.ToString()); + Assert.Null(options.Headers); } } diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/Usings.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/Usings.cs index d575c8be..05d59eeb 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/Usings.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/Usings.cs @@ -14,6 +14,5 @@ // limitations under the License. // -global using FluentAssertions; global using NSubstitute; global using Xunit; diff --git a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/VersionTests.cs b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/VersionTests.cs index cabfb3ff..230e41af 100644 --- a/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/VersionTests.cs +++ b/test/Splunk.OpenTelemetry.AutoInstrumentation.Tests/VersionTests.cs @@ -15,7 +15,6 @@ // using System.Diagnostics; -using FluentAssertions.Execution; namespace Splunk.OpenTelemetry.AutoInstrumentation.Tests { @@ -28,11 +27,8 @@ public void SplunkPluginVersion() var info = FileVersionInfo.GetVersionInfo(assembly.Location); - using (new AssertionScope()) - { - info.FileVersion.Should().NotBe("0.0.0.0"); - info.ProductVersion.Should().NotContain("0.0.0-alpha.0"); - } + Assert.NotEqual("0.0.0.0", info.FileVersion); + Assert.DoesNotContain("0.0.0-alpha.0", info.ProductVersion); } } }