diff --git a/tests/Pulse.Tests.Unit/ExporterTests.cs b/tests/Pulse.Tests.Unit/ExporterTests.cs index 4d66007..341d068 100644 --- a/tests/Pulse.Tests.Unit/ExporterTests.cs +++ b/tests/Pulse.Tests.Unit/ExporterTests.cs @@ -23,13 +23,13 @@ public void Exporter_ClearFiles() { } // Assert - dirInfo.GetFiles().Length.Should().Be(10, "because 10 files were created"); + Assert.Equal(10, dirInfo.GetFiles().Length); // Act Exporter.ClearFiles(dirInfo.FullName); // Assert - dirInfo.GetFiles().Length.Should().Be(0, "because all files were deleted"); + Assert.Empty(dirInfo.GetFiles()); } finally { dirInfo.Delete(true); } @@ -61,9 +61,9 @@ public void Exporter_ToHtmlTable_ContainsAllHeaders() { // Assert foreach (var header in headers) { - fileContent.Should().Contain(header.Key); + Assert.Contains(header.Key, fileContent); foreach (var value in header.Value) { - fileContent.Should().Contain(value); + Assert.Contains(value, fileContent); } } } @@ -91,16 +91,16 @@ public async Task Exporter_Raw_NotSuccess_ContainsAllHeadersInJson() { var expectedFileName = $"response-1337-status-code-502.json"; await Exporter.ExportRawAsync(response, string.Empty, false); - File.Exists(expectedFileName).Should().BeTrue("because the file was created"); + Assert.True(File.Exists(expectedFileName)); var fileContent = await File.ReadAllTextAsync(expectedFileName); // Assert - fileContent.Should().Contain("502", "because the status code is present"); + Assert.Contains("502", fileContent); foreach (var header in headers) { - fileContent.Should().Contain(header.Key); + Assert.Contains(header.Key, fileContent); foreach (var value in header.Value) { - fileContent.Should().Contain(value); + Assert.Contains(value, fileContent); } } @@ -110,13 +110,13 @@ public async Task Exporter_Raw_NotSuccess_ContainsAllHeadersInJson() { [Fact] public async Task Exporter_Raw_Success_ContainsOnlyContent() { // Arrange - const string content = "Hello World"; + const string expectedContent = "Hello World"; var response = new Response { Id = 1337, StatusCode = HttpStatusCode.OK, - Content = content, - ContentLength = content.Length, + Content = expectedContent, + ContentLength = expectedContent.Length, Headers = [], Exception = StrippedException.Default, Latency = TimeSpan.FromSeconds(1), @@ -127,12 +127,12 @@ public async Task Exporter_Raw_Success_ContainsOnlyContent() { var expectedFileName = $"response-1337-status-code-200.html"; await Exporter.ExportRawAsync(response, string.Empty, false); - File.Exists(expectedFileName).Should().BeTrue("because the file was created"); + Assert.True(File.Exists(expectedFileName)); var fileContent = await File.ReadAllTextAsync(expectedFileName); // Assert - fileContent.Should().Be(content, "because the status code is present"); + Assert.Equal(expectedContent, fileContent); File.Delete(expectedFileName); } @@ -140,13 +140,13 @@ public async Task Exporter_Raw_Success_ContainsOnlyContent() { [Fact] public async Task Exporter_Raw_NotSuccess_ButHasContent_ContainsOnlyContent() { // Arrange - const string content = "Hello World"; + const string expectedContent = "Hello World"; var response = new Response { Id = 1337, StatusCode = HttpStatusCode.BadGateway, - Content = content, - ContentLength = content.Length, + Content = expectedContent, + ContentLength = expectedContent.Length, Headers = [], Exception = StrippedException.Default, Latency = TimeSpan.FromSeconds(1), @@ -157,12 +157,12 @@ public async Task Exporter_Raw_NotSuccess_ButHasContent_ContainsOnlyContent() { var expectedFileName = $"response-1337-status-code-502.html"; await Exporter.ExportRawAsync(response, string.Empty, false); - File.Exists(expectedFileName).Should().BeTrue("because the file was created"); + Assert.True(File.Exists(expectedFileName)); var fileContent = await File.ReadAllTextAsync(expectedFileName); // Assert - fileContent.Should().Be(content, "because the status code is present"); + Assert.Equal(expectedContent, fileContent); File.Delete(expectedFileName); } @@ -190,8 +190,8 @@ public async Task Exporter_ExportHtmlAsync_CorrectFileName() { // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); - file[0].Name.Should().Be("response-1337-status-code-200.html", "because the file name is correct"); + Assert.Single(file); + Assert.Equal("response-1337-status-code-200.html", file[0].Name); } finally { dirInfo.Delete(true); } @@ -207,13 +207,13 @@ public async Task Exporter_ExportHtmlAsync_ContainsAllHeaders() { new("X-Custom-Header", ["value1", "value2"]) ]; - const string content = "Hello World"; + const string expectedContent = "Hello World"; var response = new Response { Id = 1337, StatusCode = HttpStatusCode.OK, - Content = content, - ContentLength = Encoding.Default.GetByteCount(content), + Content = expectedContent, + ContentLength = Encoding.Default.GetByteCount(expectedContent), Headers = headers, Exception = StrippedException.Default, Latency = TimeSpan.FromSeconds(1), @@ -225,13 +225,13 @@ public async Task Exporter_ExportHtmlAsync_ContainsAllHeaders() { // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); + Assert.Single(file); var fileContent = await File.ReadAllTextAsync(file[0].FullName); foreach (var header in headers) { - fileContent.Should().Contain(header.Key); + Assert.Contains(header.Key, fileContent); foreach (var value in header.Value) { - fileContent.Should().Contain(value); + Assert.Contains(value, fileContent); } } } finally { @@ -244,13 +244,13 @@ public async Task Exporter_ExportHtmlAsync_WithoutException_HasContent() { // Arrange var dirInfo = Directory.CreateTempSubdirectory(); try { - const string content = "Hello World"; + const string expectedContent = "Hello World"; var response = new Response { Id = 1337, StatusCode = HttpStatusCode.OK, - Content = content, - ContentLength = Encoding.Default.GetByteCount(content), + Content = expectedContent, + ContentLength = Encoding.Default.GetByteCount(expectedContent), Headers = [], Exception = StrippedException.Default, Latency = TimeSpan.FromSeconds(1), @@ -262,9 +262,9 @@ public async Task Exporter_ExportHtmlAsync_WithoutException_HasContent() { // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); + Assert.Single(file); var fileContent = await File.ReadAllTextAsync(file[0].FullName); - fileContent.Should().Contain("Hello World", "because the content is present"); + Assert.Contains(expectedContent, fileContent); } finally { dirInfo.Delete(true); } @@ -275,13 +275,13 @@ public async Task Exporter_ExportHtmlAsync_RawHtml() { // Arrange var dirInfo = Directory.CreateTempSubdirectory(); try { - const string content = "Hello World"; + const string expectedContent = "Hello World"; var response = new Response { Id = 1337, StatusCode = HttpStatusCode.OK, - Content = content, - ContentLength = Encoding.Default.GetByteCount(content), + Content = expectedContent, + ContentLength = Encoding.Default.GetByteCount(expectedContent), Headers = [], Exception = StrippedException.Default, Latency = TimeSpan.FromSeconds(1), @@ -293,9 +293,9 @@ public async Task Exporter_ExportHtmlAsync_RawHtml() { // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); + Assert.Single(file); var fileContent = await File.ReadAllTextAsync(file[0].FullName); - fileContent.Should().Be("Hello World", "because the content and only the content is present"); + Assert.Equal(expectedContent, fileContent); } finally { dirInfo.Delete(true); } @@ -310,13 +310,13 @@ public async Task Exporter_ExportHtmlAsync_RawJson() { WriteIndented = false }; - var content = JsonSerializer.Serialize(new ParametersBase(), options); + var expectedContent = JsonSerializer.Serialize(new ParametersBase(), options); var response = new Response { Id = 1337, StatusCode = HttpStatusCode.OK, - Content = content, - ContentLength = Encoding.Default.GetByteCount(content), + Content = expectedContent, + ContentLength = Encoding.Default.GetByteCount(expectedContent), Headers = [], Exception = StrippedException.Default, Latency = TimeSpan.FromSeconds(1), @@ -328,10 +328,10 @@ public async Task Exporter_ExportHtmlAsync_RawJson() { // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); + Assert.Single(file); var fileContent = await File.ReadAllTextAsync(file[0].FullName); - fileContent.Should().Be(content, "because the content and only the content is present"); - fileContent.Should().NotContain(Environment.NewLine, "because the content is not formatted"); + Assert.Equal(expectedContent, fileContent); + Assert.DoesNotContain(Environment.NewLine, fileContent); } finally { dirInfo.Delete(true); } @@ -364,9 +364,9 @@ public async Task Exporter_ExportHtmlAsync_RawJson_Formatted() { // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); + Assert.Single(file); var fileContent = await File.ReadAllTextAsync(file[0].FullName); - fileContent.Should().Contain(Environment.NewLine, "because the content is formatted"); + Assert.Contains(Environment.NewLine, fileContent); } finally { dirInfo.Delete(true); } @@ -395,10 +395,10 @@ public async Task Exporter_ExportHtmlAsync_RawJson_Exception() { // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); + Assert.Single(file); var fileContent = await File.ReadAllTextAsync(file[0].FullName); - fileContent.Should().Contain("test", "because the exception is present"); - fileContent.Should().Contain(Environment.NewLine, "because the content is formatted"); + Assert.Contains("test", fileContent); + Assert.Contains(Environment.NewLine, fileContent); } finally { dirInfo.Delete(true); } @@ -428,10 +428,10 @@ public async Task Exporter_ExportHtmlAsync_WithException_HasExceptionAndNoConten // Assert var file = dirInfo.GetFiles(); - file.Length.Should().Be(1, "because 1 file was created"); + Assert.Single(file); var fileContent = await File.ReadAllTextAsync(file[0].FullName); - fileContent.Should().NotContain("Hello World", "because the content is not present"); - fileContent.Should().Contain(exception.Message, "because the exception is present"); + Assert.DoesNotContain("Hello World", fileContent); + Assert.Contains(exception.Message, fileContent); } finally { dirInfo.Delete(true); } diff --git a/tests/Pulse.Tests.Unit/GlobalUsings.cs b/tests/Pulse.Tests.Unit/GlobalUsings.cs index 141d3a3..e11d745 100644 --- a/tests/Pulse.Tests.Unit/GlobalUsings.cs +++ b/tests/Pulse.Tests.Unit/GlobalUsings.cs @@ -1,2 +1 @@ -global using FluentAssertions; global using Bogus; \ No newline at end of file diff --git a/tests/Pulse.Tests.Unit/HelperTests.cs b/tests/Pulse.Tests.Unit/HelperTests.cs index 01f3b9b..f9ce90d 100644 --- a/tests/Pulse.Tests.Unit/HelperTests.cs +++ b/tests/Pulse.Tests.Unit/HelperTests.cs @@ -18,7 +18,7 @@ public void Extensions_GetPercentageBasedColor(double percentage, ConsoleColor e var color = Helper.GetPercentageBasedColor(percentage); // Assert - color.ConsoleColor.Should().Be(expected, "because the percentage is correct"); + Assert.Equal(expected, color.ConsoleColor); } [Theory] @@ -33,6 +33,6 @@ public void Extensions_GetStatusCodeBasedColor(HttpStatusCode statusCode, Consol var color = Helper.GetStatusCodeBasedColor((int)statusCode); // Assert - color.ConsoleColor.Should().Be(expected, "because the percentage is correct"); + Assert.Equal(expected, color.ConsoleColor); } } \ No newline at end of file diff --git a/tests/Pulse.Tests.Unit/HttpClientFactoryTests.cs b/tests/Pulse.Tests.Unit/HttpClientFactoryTests.cs index 1430e50..785ba1c 100644 --- a/tests/Pulse.Tests.Unit/HttpClientFactoryTests.cs +++ b/tests/Pulse.Tests.Unit/HttpClientFactoryTests.cs @@ -16,7 +16,7 @@ public void HttpClientFactory_DefaultTimeout_IsInfinite() { using var httpClient = PulseHttpClientFactory.Create(proxy, ParametersBase.DefaultTimeoutInMs); // Assert - httpClient.Timeout.Should().Be(Timeout.InfiniteTimeSpan, "because the default timeout is infinite"); + Assert.Equal(Timeout.InfiniteTimeSpan, httpClient.Timeout); } [Fact] @@ -28,7 +28,7 @@ public void HttpClientFactory_WithoutProxy_ReturnsHttpClient() { using var httpClient = PulseHttpClientFactory.Create(proxy, ParametersBase.DefaultTimeoutInMs); // Assert - httpClient.Should().NotBeNull("because a HttpClient is returned"); + Assert.NotNull(httpClient); } [Fact] @@ -40,7 +40,7 @@ public void CreateHandler_WithoutProxy_ReturnsSocketsHttpHandler() { using var handler = PulseHttpClientFactory.CreateHandler(proxy); // Assert - handler.Should().NotBeNull("because a handler is returned"); + Assert.NotNull(handler); } [Fact] @@ -52,7 +52,7 @@ public void CreateHandler_WithoutProxy() { using var handler = PulseHttpClientFactory.CreateHandler(proxy); // Assert - handler.Proxy.Should().BeNull("because no proxy is configured"); + Assert.Null(handler.Proxy); } [Theory] @@ -68,8 +68,8 @@ public void CreateHandler_WithProxy_HostOnly(string host, string expected) { using var handler = PulseHttpClientFactory.CreateHandler(proxy); // Assert - handler.UseProxy.Should().BeTrue("because a proxy is configured to be used"); - handler.Proxy.Should().NotBeNull("because a valid proxy should be set when UseProxy is true"); + Assert.True(handler.UseProxy); + Assert.NotNull(handler.Proxy); // Create a valid destination Uri var destination = new Uri("http://example.com"); @@ -78,7 +78,7 @@ public void CreateHandler_WithProxy_HostOnly(string host, string expected) { var proxyUri = handler.Proxy!.GetProxy(destination); // Assert that the Authority (host:port) matches the expected value - proxyUri!.Authority.Should().Be(expected, "because the proxy should point to the expected host and port"); + Assert.Equal(expected, proxyUri!.Authority); } [Fact] @@ -94,9 +94,9 @@ public void CreateHandler_WithProxy_WithoutPassword_NoCredentials() { using var handler = PulseHttpClientFactory.CreateHandler(proxy); // Assert - handler.UseProxy.Should().BeTrue("because a proxy is configured to be used"); - handler.Proxy.Should().NotBeNull("because a valid proxy should be set when UseProxy is true"); - handler.Proxy!.Credentials.Should().BeNull("because no credentials are configured"); + Assert.True(handler.UseProxy); + Assert.NotNull(handler.Proxy); + Assert.Null(handler.Proxy!.Credentials); } [Fact] @@ -113,11 +113,12 @@ public void CreateHandler_WithProxy_WithCredentials() { using var handler = PulseHttpClientFactory.CreateHandler(proxy); // Assert - handler.UseProxy.Should().BeTrue("because a proxy is configured to be used"); - handler.Proxy.Should().NotBeNull("because a valid proxy should be set when UseProxy is true"); + Assert.True(handler.UseProxy); + Assert.NotNull(handler.Proxy); + Assert.NotNull(handler.Proxy!.Credentials); var credentials = handler.Proxy!.Credentials! as NetworkCredential; - credentials.Should().NotBeNull("because credentials are configured"); - credentials!.UserName.Should().Be(proxy.Username, "because the username matches the configured username"); - credentials!.Password.Should().Be(proxy.Password, "because the password matches the configured password"); + Assert.NotNull(credentials); + Assert.Equal(proxy.Username, credentials.UserName); + Assert.Equal(proxy.Password, credentials.Password); } } \ No newline at end of file diff --git a/tests/Pulse.Tests.Unit/ParametersTests.cs b/tests/Pulse.Tests.Unit/ParametersTests.cs index 2aded09..15bad10 100644 --- a/tests/Pulse.Tests.Unit/ParametersTests.cs +++ b/tests/Pulse.Tests.Unit/ParametersTests.cs @@ -9,15 +9,15 @@ public void ParametersBase_Default() { var @params = new ParametersBase(); // Assert - @params.Requests.Should().Be(1, "because the default is 1"); - @params.ExecutionMode.Should().Be(ExecutionMode.Parallel, "because the default is parallel"); - @params.MaxConnections.Should().Be(1, "because the default is 1"); - @params.MaxConnectionsModified.Should().BeFalse("because the default is false"); - @params.FormatJson.Should().BeFalse("because the default is false"); - @params.UseFullEquality.Should().BeFalse("because the default is false"); - @params.Export.Should().BeTrue("because the default is true"); - @params.NoOp.Should().BeFalse("because the default is false"); - @params.Verbose.Should().BeFalse("because the default is false"); + Assert.Equal(1, @params.Requests); + Assert.Equal(ExecutionMode.Parallel, @params.ExecutionMode); + Assert.Equal(1, @params.MaxConnections); + Assert.False(@params.MaxConnectionsModified); + Assert.False(@params.FormatJson); + Assert.False(@params.UseFullEquality); + Assert.True(@params.Export); + Assert.False(@params.NoOp); + Assert.False(@params.Verbose); } [Fact] @@ -26,14 +26,14 @@ public void Parameters_FromBase_KeepsAllValues() { var @params = new Parameters(new ParametersBase(), CancellationToken.None); // Assert - @params.Requests.Should().Be(1, "because the default is 1"); - @params.ExecutionMode.Should().Be(ExecutionMode.Parallel, "because the default is parallel"); - @params.MaxConnections.Should().Be(1, "because the default is 1"); - @params.MaxConnectionsModified.Should().BeFalse("because the default is false"); - @params.FormatJson.Should().BeFalse("because the default is false"); - @params.UseFullEquality.Should().BeFalse("because the default is false"); - @params.Export.Should().BeTrue("because the default is true"); - @params.NoOp.Should().BeFalse("because the default is false"); - @params.Verbose.Should().BeFalse("because the default is false"); + Assert.Equal(1, @params.Requests); + Assert.Equal(ExecutionMode.Parallel, @params.ExecutionMode); + Assert.Equal(1, @params.MaxConnections); + Assert.False(@params.MaxConnectionsModified); + Assert.False(@params.FormatJson); + Assert.False(@params.UseFullEquality); + Assert.True(@params.Export); + Assert.False(@params.NoOp); + Assert.False(@params.Verbose); } } \ No newline at end of file diff --git a/tests/Pulse.Tests.Unit/Pulse.Tests.Unit.csproj b/tests/Pulse.Tests.Unit/Pulse.Tests.Unit.csproj index f941593..ba2a042 100644 --- a/tests/Pulse.Tests.Unit/Pulse.Tests.Unit.csproj +++ b/tests/Pulse.Tests.Unit/Pulse.Tests.Unit.csproj @@ -11,14 +11,13 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/Pulse.Tests.Unit/PulseMonitorTests.cs b/tests/Pulse.Tests.Unit/PulseMonitorTests.cs index 2fc1fcc..a26724d 100644 --- a/tests/Pulse.Tests.Unit/PulseMonitorTests.cs +++ b/tests/Pulse.Tests.Unit/PulseMonitorTests.cs @@ -19,6 +19,6 @@ public async Task SendAsync_ReturnsTimeoutException_OnTimeout() { // Act + Assert var context = new IPulseMonitor.RequestExecutionContext(); var result = await context.SendRequest(1, requestDetails.Request, httpClient, false, CancellationToken.None); - result.Exception.Type.Should().Be(nameof(TimeoutException)); + Assert.Equal(nameof(TimeoutException), result.Exception.Type); } } \ No newline at end of file diff --git a/tests/Pulse.Tests.Unit/SencCommandParsingTests.cs b/tests/Pulse.Tests.Unit/SencCommandParsingTests.cs index cf6e0e2..30cbea8 100644 --- a/tests/Pulse.Tests.Unit/SencCommandParsingTests.cs +++ b/tests/Pulse.Tests.Unit/SencCommandParsingTests.cs @@ -14,7 +14,7 @@ public void Arguments_Flag_NoOp() { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.NoOp.Should().BeTrue("because the flag is present"); + Assert.True(@params.NoOp); } [Theory] @@ -30,7 +30,7 @@ public void Arguments_Timeout(string arguments, int expected) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.TimeoutInMs.Should().Be(expected, "because parsed or default"); + Assert.Equal(expected, @params.TimeoutInMs); } [Theory] @@ -47,7 +47,7 @@ public void Arguments_Delay(string arguments, int expected) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.DelayInMs.Should().Be(expected, "because parsed or default"); + Assert.Equal(expected, @params.DelayInMs); } [Theory] @@ -61,7 +61,7 @@ public void Arguments_Flag_Verbose(string arguments) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.Verbose.Should().BeTrue("because the flag is present"); + Assert.True(@params.Verbose); } [Theory] @@ -75,8 +75,8 @@ public void Arguments_BatchSize_NotModified(string arguments) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.MaxConnectionsModified.Should().BeFalse("because the option is not present"); - @params.MaxConnections.Should().Be(1, "because the default is 1"); + Assert.False(@params.MaxConnectionsModified); + Assert.Equal(1, @params.MaxConnections); } [Fact] @@ -88,8 +88,8 @@ public void Arguments_MaxConnections_Modified() { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.MaxConnectionsModified.Should().BeTrue("because the option is present"); - @params.MaxConnections.Should().Be(5, "because the 5 is requested"); + Assert.True(@params.MaxConnectionsModified); + Assert.Equal(5, @params.MaxConnections); } [Theory] @@ -103,7 +103,7 @@ public void Arguments_ModeSequential(string arguments) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.ExecutionMode.Should().Be(Configuration.ExecutionMode.Sequential, "because the option is requested"); + Assert.Equal(Configuration.ExecutionMode.Sequential, @params.ExecutionMode); } [Theory] @@ -118,7 +118,7 @@ public void Arguments_ModeParallel(string arguments) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.ExecutionMode.Should().Be(Configuration.ExecutionMode.Parallel, "because the option is requested or default"); + Assert.Equal(Configuration.ExecutionMode.Parallel, @params.ExecutionMode); } [Theory] @@ -137,7 +137,7 @@ public void Arguments_NumberOfRequests(string arguments, int expected) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.Requests.Should().Be(expected, "because the option is requested or default"); + Assert.Equal(expected, @params.Requests); } [Theory] @@ -151,7 +151,7 @@ public void Arguments_NoExport(string arguments, bool expected) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.Export.Should().Be(expected, "because the option is requested or default"); + Assert.Equal(expected, @params.Export); } [Theory] @@ -165,7 +165,7 @@ public void Arguments_FormatJson(string arguments, bool expected) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.FormatJson.Should().Be(expected, "because the option is requested or default"); + Assert.Equal(expected, @params.FormatJson); } [Theory] @@ -179,6 +179,6 @@ public void Arguments_UseFullEquality(string arguments, bool expected) { var @params = SendCommand.ParseParametersArgs(args); // Assert - @params.UseFullEquality.Should().Be(expected, "because the option is requested or default"); + Assert.Equal(expected, @params.UseFullEquality); } } \ No newline at end of file diff --git a/tests/Pulse.Tests.Unit/StrippedExceptionTests.cs b/tests/Pulse.Tests.Unit/StrippedExceptionTests.cs index 30afb10..3e327b1 100644 --- a/tests/Pulse.Tests.Unit/StrippedExceptionTests.cs +++ b/tests/Pulse.Tests.Unit/StrippedExceptionTests.cs @@ -9,9 +9,9 @@ public void StrippedException_Default_AllEmpty() { var exception = StrippedException.Default; // Assert - exception.IsDefault.Should().BeTrue("because the exception is the default"); - exception.Type.Should().BeEmpty("because the exception is the default"); - exception.Message.Should().BeEmpty("because the exception is the default"); + Assert.True(exception.IsDefault); + Assert.Empty(exception.Type); + Assert.Empty(exception.Message); } [Fact] @@ -20,9 +20,9 @@ public void StrippedException_JsonCtor_YieldsDefault() { var exception = new StrippedException(); // Assert - exception.IsDefault.Should().BeTrue("because the exception is the default"); - exception.Type.Should().BeEmpty("because the exception is the default"); - exception.Message.Should().BeEmpty("because the exception is the default"); + Assert.True(exception.IsDefault); + Assert.Empty(exception.Type); + Assert.Empty(exception.Message); } [Fact] @@ -31,9 +31,9 @@ public void StrippedException_FromException_NullYieldsDefault() { var exception = StrippedException.FromException(null); // Assert - exception.IsDefault.Should().BeTrue("because the exception is the default"); - exception.Type.Should().BeEmpty("because the exception is the default"); - exception.Message.Should().BeEmpty("because the exception is the default"); + Assert.True(exception.IsDefault); + Assert.Empty(exception.Type); + Assert.Empty(exception.Message); } [Fact] @@ -45,8 +45,8 @@ public void StrippedException_FromException_ExceptionYieldsTypeAndMessage() { var stripped = StrippedException.FromException(exception); // Assert - stripped.IsDefault.Should().BeFalse("because the exception is not the default"); - stripped.Type.Should().Be(exception.GetType().Name, "because the exception type is correct"); - stripped.Message.Should().Be(exception.Message, "because the exception message is correct"); + Assert.False(stripped.IsDefault); + Assert.Equal(exception.GetType().Name, stripped.Type); + Assert.Equal(exception.Message, stripped.Message); } } \ No newline at end of file diff --git a/tests/Pulse.Tests.Unit/SummaryTests.cs b/tests/Pulse.Tests.Unit/SummaryTests.cs index ca0c44f..f7baaeb 100644 --- a/tests/Pulse.Tests.Unit/SummaryTests.cs +++ b/tests/Pulse.Tests.Unit/SummaryTests.cs @@ -13,7 +13,7 @@ public void Summary_Mean_ReturnsCorrectValue() { var actual = PulseSummary.Mean(arr); // Assert - actual.Should().BeApproximately(expected, 0.01, "because the sum is correct"); + Assert.Equal(expected, actual, 0.01); } [Theory] @@ -23,10 +23,10 @@ public void GetSummary_TheoryTests(double[] values, bool removeOutliers, double var summary = PulseSummary.GetSummary(values, removeOutliers); // Assert - summary.Min.Should().BeApproximately(expectedMin, 0.01, "because the min is correct"); - summary.Max.Should().BeApproximately(expectedMax, 0.01, "because the max is correct"); - summary.Mean.Should().BeApproximately(expectedAvg, 0.01, "because the avg is correct"); - summary.Removed.Should().Be(expectedRemoved, "because the removed count is correct"); + Assert.Equal(expectedMin, summary.Min, 0.01); + Assert.Equal(expectedMax, summary.Max, 0.01); + Assert.Equal(expectedAvg, summary.Mean, 0.01); + Assert.Equal(expectedRemoved, summary.Removed, 0.01); } private class SummaryTestData : TheoryData { diff --git a/tests/Pulse.Tests.Unit/VersionTests.cs b/tests/Pulse.Tests.Unit/VersionTests.cs index 8cc0776..80d2321 100644 --- a/tests/Pulse.Tests.Unit/VersionTests.cs +++ b/tests/Pulse.Tests.Unit/VersionTests.cs @@ -8,6 +8,6 @@ public void Assembly_Version_Matching() { var assemblyVersion = typeof(Program).Assembly.GetName().Version!; // Assert - constantVersion.Should().Be(assemblyVersion); + Assert.Equal(assemblyVersion, constantVersion); } } \ No newline at end of file