Skip to content

Commit

Permalink
Autoformat of test projects for NUnit2045
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmarbach committed Aug 19, 2024
1 parent d28f13f commit 60c8d48
Show file tree
Hide file tree
Showing 116 changed files with 1,751 additions and 955 deletions.
39 changes: 27 additions & 12 deletions src/Particular.LicensingComponent.UnitTests/AuditQuery_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ public async Task Should_return_known_endpoints_if_any()
//Assert
Assert.That(endpoints, Is.Not.Null, "Endpoints should be found");
Assert.That(endpoints.Count, Is.EqualTo(2), "Invalid number of on known endpoints");
Assert.That(endpoints.Any(a => a.Name == "Endpoint1"), Is.True, "Should have found Endpoint1");
Assert.That(endpoints.Any(a => a.Name == "Endpoint2"), Is.True, "Should have found Endpoint2");
Assert.Multiple(() =>
{
Assert.That(endpoints.Any(a => a.Name == "Endpoint1"), Is.True, "Should have found Endpoint1");
Assert.That(endpoints.Any(a => a.Name == "Endpoint2"), Is.True, "Should have found Endpoint2");
});
}

[Test]
Expand All @@ -52,10 +55,13 @@ public async Task Should_return_audit_remotes()
//Assert
Assert.That(remotes, Is.Not.Null, "Remotes should be found");
Assert.That(remotes.Count, Is.EqualTo(1), "Invalid number of remotes");
Assert.That(remotes[0].ApiUri, Is.EqualTo("http://localhost:44444/api/"), "Invalid ApiUri on remote");
Assert.That(remotes[0].VersionString, Is.EqualTo("5.1.0"), "Invalid VersionString on remote");
Assert.That(remotes[0].Retention, Is.EqualTo(new TimeSpan(7, 0, 0, 0)), "Invalid Retention on remote");
Assert.That(remotes[0].Queues, Is.Not.Null, "Queues should be reported on remote");
Assert.Multiple(() =>
{
Assert.That(remotes[0].ApiUri, Is.EqualTo("http://localhost:44444/api/"), "Invalid ApiUri on remote");
Assert.That(remotes[0].VersionString, Is.EqualTo("5.1.0"), "Invalid VersionString on remote");
Assert.That(remotes[0].Retention, Is.EqualTo(new TimeSpan(7, 0, 0, 0)), "Invalid Retention on remote");
Assert.That(remotes[0].Queues, Is.Not.Null, "Queues should be reported on remote");
});
Assert.That(remotes[0].Queues.Count, Is.EqualTo(2), "Invalid number of queues reported on remote");
Assert.That(remotes[0].Queues, Does.Contain("audit"), "Should have foind audit queue");
Assert.That(remotes[0].Queues, Does.Contain("audit.log"), "Should have found audit.log queue");
Expand All @@ -72,8 +78,11 @@ public async Task Should_return_successful_audit_connection_if_instances_exist_a

//Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.True, "Connection status should be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0), "Unexpected ConnectionErrorMessages");
Assert.Multiple(() =>
{
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.True, "Connection status should be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0), "Unexpected ConnectionErrorMessages");
});

Approver.Verify(connectionSettingsResult.Diagnostics);
}
Expand All @@ -91,8 +100,11 @@ public async Task Should_return_diagnostics_and_no_errors_when_no_remotes_define

//Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.True, "Connection status should be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0), "Unexpected ConnectionErrorMessages");
Assert.Multiple(() =>
{
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.True, "Connection status should be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0), "Unexpected ConnectionErrorMessages");
});

Approver.Verify(connectionSettingsResult.Diagnostics);
}
Expand All @@ -113,8 +125,11 @@ public async Task Should_always_return_diagnostics_and_relevant_errors_when_inva

//Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.False, "Connection status should not be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.Not.EqualTo(0), "Expected ConnectionErrorMessages");
Assert.Multiple(() =>
{
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.False, "Connection status should not be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.Not.EqualTo(0), "Expected ConnectionErrorMessages");
});

Approver.Verify(connectionSettingsResult.Diagnostics, scenario: $"status_{remoteStatus}.version_{remoteVersion?.Replace(".", "") ?? "null"}.retention_{retensionPeriod[0]}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,26 @@ await Task.Run(async () =>

// Assert
Assert.That(foundEndpoint, Is.Not.Null, $"Expected to find endpoint {endpointName}");
Assert.That(foundEndpoint.Id.Name, Is.EqualTo(endpointName), $"Expected name to be {endpointName}");
Assert.Multiple(() =>
{
Assert.That(foundEndpoint.Id.Name, Is.EqualTo(endpointName), $"Expected name to be {endpointName}");

Assert.That(foundEndpointThroughput, Is.Not.Null, "Expected endpoint throughput");
Assert.That(foundEndpointThroughput.ContainsKey(endpointName), Is.True,
$"Expected throughput for {endpointName}");
Assert.That(foundEndpointThroughput, Is.Not.Null, "Expected endpoint throughput");
});
Assert.Multiple(() =>
{
Assert.That(foundEndpointThroughput.ContainsKey(endpointName), Is.True,
$"Expected throughput for {endpointName}");

Assert.That(throughputData.Length, Is.EqualTo(1), $"Expected 1 throughput data for {endpointName}");
Assert.That(throughputData[0].ContainsKey(throughputDate), Is.True,
$"Expected throughput for {throughputDate}");
Assert.That(throughputData[0][throughputDate], Is.EqualTo(throughputCount),
$"Expected throughput for {throughputDate} to be {throughputCount}");
Assert.That(throughputData.Length, Is.EqualTo(1), $"Expected 1 throughput data for {endpointName}");
});
Assert.Multiple(() =>
{
Assert.That(throughputData[0].ContainsKey(throughputDate), Is.True,
$"Expected throughput for {throughputDate}");
Assert.That(throughputData[0][throughputDate], Is.EqualTo(throughputCount),
$"Expected throughput for {throughputDate} to be {throughputCount}");
});
}

class AuditQuery_NoAuditRemotes : IAuditQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ await Task.Run(async () =>
} while (!token.IsCancellationRequested);
});

Assert.That(mockedBrokerThroughputQueryThatThrowsExceptions.GetQueueNamesCalls, Is.GreaterThan(1));
Assert.That(mockedBrokerThroughputQueryThatThrowsExceptions.GetGetThroughputPerDay, Is.GreaterThan(1));
Assert.Multiple(() =>
{
Assert.That(mockedBrokerThroughputQueryThatThrowsExceptions.GetQueueNamesCalls, Is.GreaterThan(1));
Assert.That(mockedBrokerThroughputQueryThatThrowsExceptions.GetGetThroughputPerDay, Is.GreaterThan(1));
});
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,33 @@ public async Task Should_record_new_endpoint_and_throughput()

// Assert
Assert.That(foundEndpoint, Is.Not.Null, "Expected to find Endpoint1");
Assert.That(foundEndpoint.Id.Name, Is.EqualTo("Endpoint1"), "Expected name to be Endpoint1");
Assert.That(foundEndpoint.EndpointIndicators, Is.Not.Null, "Expected to find endpoint indicators");
Assert.That(foundEndpoint.EndpointIndicators, Does.Contain(EndpointIndicator.KnownEndpoint.ToString()),
"Expected KnownEndpoint indicator");

Assert.That(foundEndpointThroughput, Is.Not.Null, "Expected endpoint throughput");
Assert.That(foundEndpointThroughput.ContainsKey("Endpoint1"), Is.True, "Expected throughput for Endpoint1");

Assert.That(throughputData.Length, Is.EqualTo(1), "Expected 1 throughput data for Endpoint1");
Assert.That(throughputData[0].ThroughputSource, Is.EqualTo(ThroughputSource.Monitoring),
"Expected ThroughputSource to be Monitoring for Endpoint1");
Assert.That(throughputData[0].Keys.Contains(DateOnly.FromDateTime(message.EndDateTime.Date)), Is.True,
$"Expected throughput for {message.StartDateTime.Date} for Endpoint1");
Assert.That(throughputData[0][DateOnly.FromDateTime(message.EndDateTime.Date)], Is.EqualTo(15),
$"Expected throughput for {message.StartDateTime.Date} to be 15 for Endpoint1");
Assert.Multiple(() =>
{
Assert.That(foundEndpoint.Id.Name, Is.EqualTo("Endpoint1"), "Expected name to be Endpoint1");
Assert.That(foundEndpoint.EndpointIndicators, Is.Not.Null, "Expected to find endpoint indicators");
});
Assert.Multiple(() =>
{
Assert.That(foundEndpoint.EndpointIndicators, Does.Contain(EndpointIndicator.KnownEndpoint.ToString()),
"Expected KnownEndpoint indicator");

Assert.That(foundEndpointThroughput, Is.Not.Null, "Expected endpoint throughput");
});
Assert.Multiple(() =>
{
Assert.That(foundEndpointThroughput.ContainsKey("Endpoint1"), Is.True, "Expected throughput for Endpoint1");

Assert.That(throughputData.Length, Is.EqualTo(1), "Expected 1 throughput data for Endpoint1");
});
Assert.Multiple(() =>
{
Assert.That(throughputData[0].ThroughputSource, Is.EqualTo(ThroughputSource.Monitoring),
"Expected ThroughputSource to be Monitoring for Endpoint1");
Assert.That(throughputData[0].Keys.Contains(DateOnly.FromDateTime(message.EndDateTime.Date)), Is.True,
$"Expected throughput for {message.StartDateTime.Date} for Endpoint1");
Assert.That(throughputData[0][DateOnly.FromDateTime(message.EndDateTime.Date)], Is.EqualTo(15),
$"Expected throughput for {message.StartDateTime.Date} to be 15 for Endpoint1");
});
}

[Test]
Expand Down Expand Up @@ -107,10 +119,13 @@ public async Task Should_return_successful_monitoring_connection_and_diagnostics

// Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.True, "Connection status should be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0),
"Unexpected ConnectionErrorMessages");
Assert.That(connectionSettingsResult.Diagnostics, Is.Not.Null, "Expected diagnostic");
Assert.Multiple(() =>
{
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.True, "Connection status should be successful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0),
"Unexpected ConnectionErrorMessages");
Assert.That(connectionSettingsResult.Diagnostics, Is.Not.Null, "Expected diagnostic");
});
Assert.That(
connectionSettingsResult.Diagnostics.Contains("Throughput from Monitoring recorded",
StringComparison.OrdinalIgnoreCase), Is.True, "Expected diagnostics not found");
Expand All @@ -133,11 +148,14 @@ public async Task Should_return_error_monitoring_connection_and_diagnostics_if_n

// Assert
Assert.That(connectionSettingsResult, Is.Not.Null, "connectionSettingsResult should be returned");
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.False,
"Connection status should be unsuccessful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0),
"Unexpected ConnectionErrorMessages");
Assert.That(connectionSettingsResult.Diagnostics, Is.Not.Null, "Expected diagnostic");
Assert.Multiple(() =>
{
Assert.That(connectionSettingsResult.ConnectionSuccessful, Is.False,
"Connection status should be unsuccessful");
Assert.That(connectionSettingsResult.ConnectionErrorMessages.Count, Is.EqualTo(0),
"Unexpected ConnectionErrorMessages");
Assert.That(connectionSettingsResult.Diagnostics, Is.Not.Null, "Expected diagnostic");
});
Assert.That(
connectionSettingsResult.Diagnostics.Contains("No throughput from Monitoring recorded",
StringComparison.OrdinalIgnoreCase), Is.True, "Expected diagnostics not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ await DataStore.CreateBuilder()
// Act
var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);

// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.True);
Assert.That(reportGenerationState.Reason, Is.EqualTo(""));
Assert.Multiple(() =>
{
// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.True);
Assert.That(reportGenerationState.Reason, Is.EqualTo(""));
});
}


Expand All @@ -44,9 +47,12 @@ await DataStore.CreateBuilder()
// Act
var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);

// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.True);
Assert.That(reportGenerationState.Reason, Is.EqualTo(""));
Assert.Multiple(() =>
{
// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.True);
Assert.That(reportGenerationState.Reason, Is.EqualTo(""));
});
}

[Test]
Expand All @@ -62,9 +68,12 @@ await DataStore.CreateBuilder()
// Act
var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);

// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.False);
Assert.That(reportGenerationState.Reason, Does.Contain("one day"), "Report generation failure reason does not contain 'one day'");
Assert.Multiple(() =>
{
// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.False);
Assert.That(reportGenerationState.Reason, Does.Contain("one day"), "Report generation failure reason does not contain 'one day'");
});
Assert.That(reportGenerationState.Reason, Does.Contain("broker"), "Report generation failure reason does not contain 'broker'");
}

Expand All @@ -80,9 +89,12 @@ await DataStore.CreateBuilder().AddEndpoint()
// Act
var reportGenerationState = await ThroughputCollector.GetReportGenerationState(default);

// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.False);
Assert.That(reportGenerationState.Reason, Does.Contain("one day"), "Report generation failure reason does not contain 'one day'");
Assert.Multiple(() =>
{
// Assert
Assert.That(reportGenerationState.ReportCanBeGenerated, Is.False);
Assert.That(reportGenerationState.Reason, Does.Contain("one day"), "Report generation failure reason does not contain 'one day'");
});
Assert.That(reportGenerationState.Reason, Does.Contain("broker"), "Report generation failure reason does not contain 'broker'");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ await DataStore.CreateBuilder()
Assert.That(report, Is.Not.Null);
Assert.That(report.ReportData.Queues.Count, Is.EqualTo(3));

Assert.That(report.ReportData.StartTime, Is.EqualTo(minDateInReport), $"Incorrect StartTime for report");
Assert.That(report.ReportData.EndTime, Is.EqualTo(reportEndDate), $"Incorrect StartTime for report");
Assert.That(report.ReportData.ReportDuration, Is.EqualTo(reportEndDate - minDateInReport), $"Incorrect ReportDuration for report");
Assert.Multiple(() =>
{
Assert.That(report.ReportData.StartTime, Is.EqualTo(minDateInReport), $"Incorrect StartTime for report");
Assert.That(report.ReportData.EndTime, Is.EqualTo(reportEndDate), $"Incorrect StartTime for report");
Assert.That(report.ReportData.ReportDuration, Is.EqualTo(reportEndDate - minDateInReport), $"Incorrect ReportDuration for report");
});
}
}
Loading

0 comments on commit 60c8d48

Please sign in to comment.