From 1e1f7a0c0b91b1d8ba37baf447a06d468266ba80 Mon Sep 17 00:00:00 2001 From: Gabriela Trutan Date: Wed, 8 Jan 2025 18:06:48 +0100 Subject: [PATCH] SLVS-1498 Improve test coverage --- .../Http/HttpConfigurationListenerTests.cs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/SLCore.Listeners.UnitTests/Implementation/Http/HttpConfigurationListenerTests.cs b/src/SLCore.Listeners.UnitTests/Implementation/Http/HttpConfigurationListenerTests.cs index f8869f51f..4ab597b88 100644 --- a/src/SLCore.Listeners.UnitTests/Implementation/Http/HttpConfigurationListenerTests.cs +++ b/src/SLCore.Listeners.UnitTests/Implementation/Http/HttpConfigurationListenerTests.cs @@ -221,14 +221,24 @@ public async Task CheckServerTrustedAsync_CertificateIsValid_DoesNotShowNotifica private static string BuildUri(string scheme, string host) => $"{scheme}://{host}"; - private static bool IsExpectedNotification(INotification x) => - x.Id == HttpConfigurationListener.ServerCertificateInvalidNotificationId - && x.Message == SLCoreStrings.ServerCertificateInfobar_CertificateInvalidMessage - && HasExpectedActions(x); + private bool IsExpectedNotification(INotification x) + { + VerifyNotificationHasExpectedActions(x); + + return x.Id == HttpConfigurationListener.ServerCertificateInvalidNotificationId && x.Message == SLCoreStrings.ServerCertificateInfobar_CertificateInvalidMessage; + } - private static bool HasExpectedActions(INotification notification) => - notification.Actions.Count() == 2 - && notification.Actions.Any(x => x.CommandText == SLCoreStrings.ServerCertificateInfobar_LearnMore) - && notification.Actions.Any(x => x.CommandText == SLCoreStrings.ServerCertificateInfobar_ShowLogs); + private void VerifyNotificationHasExpectedActions(INotification notification) + { + notification.Actions.Should().HaveCount(2); + notification.Actions.Should().Contain(x => IsExpectedAction(x, SLCoreStrings.ServerCertificateInfobar_LearnMore)); + notification.Actions.Should().Contain(x => IsExpectedAction(x, SLCoreStrings.ServerCertificateInfobar_ShowLogs)); + + notification.Actions.First().Action.Invoke(null); + notification.Actions.Last().Action.Invoke(null); + browserService.Received(1).Navigate(DocumentationLinks.SslCertificate); + outputWindowService.Received(1).Show(); + } + private static bool IsExpectedAction(INotificationAction notificationAction, string expectedText) => notificationAction.CommandText == expectedText && !notificationAction.ShouldDismissAfterAction; }