diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardConnectionOptionsTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardConnectionOptionsTests.cs index 0baac136..8fedbd2d 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardConnectionOptionsTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardConnectionOptionsTests.cs @@ -1,6 +1,6 @@ using System; +using System.Linq; using DotNetWorkQueue.Dashboard.Api.Configuration; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration @@ -13,8 +13,8 @@ public void AddQueue_Adds_To_List() { var opts = new DashboardConnectionOptions(); opts.AddQueue("TestQueue"); - opts.Queues.Should().HaveCount(1); - opts.Queues[0].QueueName.Should().Be("TestQueue"); + Assert.AreEqual(1, (opts.Queues).Count()); + Assert.AreEqual("TestQueue", opts.Queues[0].QueueName); } [TestMethod] @@ -22,7 +22,7 @@ public void AddQueue_Without_Interceptors_Has_Null_Config() { var opts = new DashboardConnectionOptions(); opts.AddQueue("TestQueue"); - opts.Queues[0].InterceptorConfiguration.Should().BeNull(); + Assert.IsNull(opts.Queues[0].InterceptorConfiguration); } [TestMethod] @@ -31,8 +31,8 @@ public void AddQueue_With_Interceptors_Stores_Config() var opts = new DashboardConnectionOptions(); Action config = c => { }; opts.AddQueue("TestQueue", config); - opts.Queues[0].InterceptorConfiguration.Should().NotBeNull(); - opts.Queues[0].InterceptorConfiguration.Should().BeSameAs(config); + Assert.IsNotNull(opts.Queues[0].InterceptorConfiguration); + Assert.AreSame(config, opts.Queues[0].InterceptorConfiguration); } [TestMethod] @@ -42,7 +42,7 @@ public void AddQueue_Multiple_Queues() opts.AddQueue("Queue1"); opts.AddQueue("Queue2"); opts.AddQueue("Queue3"); - opts.Queues.Should().HaveCount(3); + Assert.AreEqual(3, (opts.Queues).Count()); } [TestMethod] @@ -50,10 +50,10 @@ public void AddQueueWithProfile_Stores_Profile_Name() { var opts = new DashboardConnectionOptions(); opts.AddQueueWithProfile("TestQueue", "encrypted"); - opts.Queues.Should().HaveCount(1); - opts.Queues[0].QueueName.Should().Be("TestQueue"); - opts.Queues[0].InterceptorProfile.Should().Be("encrypted"); - opts.Queues[0].InterceptorConfiguration.Should().BeNull(); + Assert.AreEqual(1, (opts.Queues).Count()); + Assert.AreEqual("TestQueue", opts.Queues[0].QueueName); + Assert.AreEqual("encrypted", opts.Queues[0].InterceptorProfile); + Assert.IsNull(opts.Queues[0].InterceptorConfiguration); } [TestMethod] @@ -65,10 +65,10 @@ public void AddQueue_With_InterceptorOptions_Stores_Options() GZip = new GZipInterceptorOptions { MinimumSize = 200 } }; opts.AddQueue("TestQueue", interceptors); - opts.Queues.Should().HaveCount(1); - opts.Queues[0].QueueName.Should().Be("TestQueue"); - opts.Queues[0].Interceptors.Should().BeSameAs(interceptors); - opts.Queues[0].InterceptorConfiguration.Should().BeNull(); + Assert.AreEqual(1, (opts.Queues).Count()); + Assert.AreEqual("TestQueue", opts.Queues[0].QueueName); + Assert.AreSame(interceptors, opts.Queues[0].Interceptors); + Assert.IsNull(opts.Queues[0].InterceptorConfiguration); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardInterceptorOptionsTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardInterceptorOptionsTests.cs index 7359fdd7..ee8613aa 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardInterceptorOptionsTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardInterceptorOptionsTests.cs @@ -1,5 +1,4 @@ using DotNetWorkQueue.Dashboard.Api.Configuration; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration @@ -11,32 +10,32 @@ public class DashboardInterceptorOptionsTests public void Defaults_Are_Null() { var opts = new DashboardInterceptorOptions(); - opts.GZip.Should().BeNull(); - opts.TripleDes.Should().BeNull(); + Assert.IsNull(opts.GZip); + Assert.IsNull(opts.TripleDes); } [TestMethod] public void GZip_Defaults() { var opts = new GZipInterceptorOptions(); - opts.Enabled.Should().BeTrue(); - opts.MinimumSize.Should().Be(150); + Assert.IsTrue(opts.Enabled); + Assert.AreEqual(150, opts.MinimumSize); } [TestMethod] public void GZip_MinimumSize_Can_Be_Set() { var opts = new GZipInterceptorOptions { MinimumSize = 500 }; - opts.MinimumSize.Should().Be(500); + Assert.AreEqual(500, opts.MinimumSize); } [TestMethod] public void TripleDes_Defaults() { var opts = new TripleDesInterceptorOptions(); - opts.Enabled.Should().BeTrue(); - opts.Key.Should().BeNull(); - opts.IV.Should().BeNull(); + Assert.IsTrue(opts.Enabled); + Assert.IsNull(opts.Key); + Assert.IsNull(opts.IV); } [TestMethod] @@ -47,8 +46,8 @@ public void TripleDes_Can_Be_Set() Key = "dGVzdGtleQ==", IV = "dGVzdGl2" }; - opts.Key.Should().Be("dGVzdGtleQ=="); - opts.IV.Should().Be("dGVzdGl2"); + Assert.AreEqual("dGVzdGtleQ==", opts.Key); + Assert.AreEqual("dGVzdGl2", opts.IV); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardOptionsTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardOptionsTests.cs index 9a36f442..24a20b24 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardOptionsTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardOptionsTests.cs @@ -1,6 +1,6 @@ using System; +using System.Linq; using DotNetWorkQueue.Dashboard.Api.Configuration; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration @@ -12,22 +12,22 @@ public class DashboardOptionsTests public void Defaults_Are_Correct() { var opts = new DashboardOptions(); - opts.EnableSwagger.Should().BeTrue(); - opts.AuthorizationPolicy.Should().BeNull(); + Assert.IsTrue(opts.EnableSwagger); + Assert.IsNull(opts.AuthorizationPolicy); } [TestMethod] public void EnableSwagger_Can_Be_Disabled() { var opts = new DashboardOptions { EnableSwagger = false }; - opts.EnableSwagger.Should().BeFalse(); + Assert.IsFalse(opts.EnableSwagger); } [TestMethod] public void AuthorizationPolicy_Can_Be_Set() { var opts = new DashboardOptions { AuthorizationPolicy = "AdminOnly" }; - opts.AuthorizationPolicy.Should().Be("AdminOnly"); + Assert.AreEqual("AdminOnly", opts.AuthorizationPolicy); } [TestMethod] @@ -36,8 +36,8 @@ public void AddInterceptorProfile_Stores_Profile() var opts = new DashboardOptions(); Action action = _ => { }; opts.AddInterceptorProfile("encrypted", action); - opts.InterceptorProfiles.Should().ContainKey("encrypted"); - opts.InterceptorProfiles["encrypted"].Should().BeSameAs(action); + Assert.IsTrue((opts.InterceptorProfiles).ContainsKey("encrypted")); + Assert.AreSame(action, opts.InterceptorProfiles["encrypted"]); } [TestMethod] @@ -46,7 +46,7 @@ public void AddInterceptorProfile_Is_Case_Insensitive() var opts = new DashboardOptions(); Action action = _ => { }; opts.AddInterceptorProfile("Encrypted", action); - opts.InterceptorProfiles.Should().ContainKey("encrypted"); + Assert.IsTrue((opts.InterceptorProfiles).ContainsKey("encrypted")); } [TestMethod] @@ -57,7 +57,7 @@ public void AddInterceptorProfile_Overwrites_Existing() Action second = _ => { }; opts.AddInterceptorProfile("encrypted", first); opts.AddInterceptorProfile("encrypted", second); - opts.InterceptorProfiles["encrypted"].Should().BeSameAs(second); + Assert.AreSame(second, opts.InterceptorProfiles["encrypted"]); } [TestMethod] @@ -65,7 +65,7 @@ public void AddInterceptorProfile_Throws_On_Null_Name() { var opts = new DashboardOptions(); Action act = () => opts.AddInterceptorProfile(null, _ => { }); - act.Should().Throw(); + Assert.Throws(act); } [TestMethod] @@ -73,7 +73,7 @@ public void AddInterceptorProfile_Throws_On_Empty_Name() { var opts = new DashboardOptions(); Action act = () => opts.AddInterceptorProfile("", _ => { }); - act.Should().Throw(); + Assert.Throws(act); } [TestMethod] @@ -81,21 +81,21 @@ public void AddInterceptorProfile_Throws_On_Null_Action() { var opts = new DashboardOptions(); Action act = () => opts.AddInterceptorProfile("test", null); - act.Should().Throw(); + Assert.Throws(act); } [TestMethod] public void EnableCors_Defaults_To_False() { var opts = new DashboardOptions(); - opts.EnableCors.Should().BeFalse(); + Assert.IsFalse(opts.EnableCors); } [TestMethod] public void CorsOrigins_Defaults_To_Empty() { var opts = new DashboardOptions(); - opts.CorsOrigins.Should().BeEmpty(); + Assert.IsFalse((opts.CorsOrigins).Any()); } [TestMethod] @@ -106,15 +106,16 @@ public void CorsOrigins_Can_Be_Set() EnableCors = true, CorsOrigins = new[] { "http://localhost:5000" } }; - opts.EnableCors.Should().BeTrue(); - opts.CorsOrigins.Should().ContainSingle().Which.Should().Be("http://localhost:5000"); + Assert.IsTrue(opts.EnableCors); + Assert.AreEqual(1, (opts.CorsOrigins).Count()); + Assert.AreEqual("http://localhost:5000", (opts.CorsOrigins).Single()); } [TestMethod] public void AssemblyPaths_Defaults_To_Empty() { var opts = new DashboardOptions(); - opts.AssemblyPaths.Should().BeEmpty(); + Assert.IsFalse((opts.AssemblyPaths).Any()); } [TestMethod] @@ -124,9 +125,9 @@ public void AssemblyPaths_Can_Be_Set() { AssemblyPaths = new[] { "/app/plugins", "/opt/dlls" } }; - opts.AssemblyPaths.Should().HaveCount(2); - opts.AssemblyPaths[0].Should().Be("/app/plugins"); - opts.AssemblyPaths[1].Should().Be("/opt/dlls"); + Assert.AreEqual(2, (opts.AssemblyPaths).Count()); + Assert.AreEqual("/app/plugins", opts.AssemblyPaths[0]); + Assert.AreEqual("/opt/dlls", opts.AssemblyPaths[1]); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardQueueOptionsTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardQueueOptionsTests.cs index dcafe822..23bf1dea 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardQueueOptionsTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/DashboardQueueOptionsTests.cs @@ -1,5 +1,4 @@ using DotNetWorkQueue.Dashboard.Api.Configuration; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration @@ -11,35 +10,35 @@ public class DashboardQueueOptionsTests public void QueueName_Can_Be_Set() { var opts = new DashboardQueueOptions { QueueName = "MyQueue" }; - opts.QueueName.Should().Be("MyQueue"); + Assert.AreEqual("MyQueue", opts.QueueName); } [TestMethod] public void InterceptorConfiguration_Defaults_To_Null() { var opts = new DashboardQueueOptions(); - opts.InterceptorConfiguration.Should().BeNull(); + Assert.IsNull(opts.InterceptorConfiguration); } [TestMethod] public void InterceptorProfile_Defaults_To_Null() { var opts = new DashboardQueueOptions(); - opts.InterceptorProfile.Should().BeNull(); + Assert.IsNull(opts.InterceptorProfile); } [TestMethod] public void InterceptorProfile_Can_Be_Set() { var opts = new DashboardQueueOptions { InterceptorProfile = "encrypted" }; - opts.InterceptorProfile.Should().Be("encrypted"); + Assert.AreEqual("encrypted", opts.InterceptorProfile); } [TestMethod] public void Interceptors_Defaults_To_Null() { var opts = new DashboardQueueOptions(); - opts.Interceptors.Should().BeNull(); + Assert.IsNull(opts.Interceptors); } [TestMethod] @@ -50,7 +49,7 @@ public void Interceptors_Can_Be_Set() GZip = new GZipInterceptorOptions() }; var opts = new DashboardQueueOptions { Interceptors = interceptors }; - opts.Interceptors.Should().BeSameAs(interceptors); + Assert.AreSame(interceptors, opts.Interceptors); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/InterceptorConfigurationBuilderTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/InterceptorConfigurationBuilderTests.cs index 657bcfe1..d1902c79 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/InterceptorConfigurationBuilderTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Configuration/InterceptorConfigurationBuilderTests.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using DotNetWorkQueue.Dashboard.Api.Configuration; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Configuration @@ -17,7 +16,7 @@ public void Returns_Null_When_Nothing_Configured() { var queueOptions = new DashboardQueueOptions { QueueName = "test" }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - result.Should().BeNull(); + Assert.IsNull(result); } [TestMethod] @@ -30,7 +29,7 @@ public void Returns_Explicit_Delegate_When_Set() InterceptorConfiguration = expected }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - result.Should().BeSameAs(expected); + Assert.AreSame(expected, result); } [TestMethod] @@ -48,7 +47,7 @@ public void Explicit_Delegate_Takes_Priority_Over_Profile() InterceptorProfile = "encrypted" }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, profiles); - result.Should().BeSameAs(expected); + Assert.AreSame(expected, result); } [TestMethod] @@ -65,7 +64,7 @@ public void Returns_Profile_When_Name_Matches() InterceptorProfile = "encrypted" }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, profiles); - result.Should().BeSameAs(profileAction); + Assert.AreSame(profileAction, result); } [TestMethod] @@ -82,7 +81,7 @@ public void Profile_Lookup_Is_Case_Insensitive() InterceptorProfile = "ENCRYPTED" }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, profiles); - result.Should().BeSameAs(profileAction); + Assert.AreSame(profileAction, result); } [TestMethod] @@ -94,8 +93,8 @@ public void Throws_When_Profile_Not_Found() InterceptorProfile = "missing" }; Action act = () => InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - act.Should().Throw() - .WithMessage("*missing*"); + var ex = Assert.Throws(act); + Assert.IsTrue(ex.Message.Contains("missing", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -116,7 +115,7 @@ public void Profile_Takes_Priority_Over_Json_Options() } }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, profiles); - result.Should().BeSameAs(profileAction); + Assert.AreSame(profileAction, result); } [TestMethod] @@ -132,7 +131,7 @@ public void Returns_Null_When_Json_Options_All_Disabled() } }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - result.Should().BeNull(); + Assert.IsNull(result); } [TestMethod] @@ -147,7 +146,7 @@ public void Returns_Action_When_GZip_Enabled() } }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - result.Should().NotBeNull(); + Assert.IsNotNull(result); } [TestMethod] @@ -166,7 +165,7 @@ public void Returns_Action_When_TripleDes_Enabled() } }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - result.Should().NotBeNull(); + Assert.IsNotNull(result); } [TestMethod] @@ -181,8 +180,8 @@ public void Throws_When_TripleDes_Missing_Key() } }; Action act = () => InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - act.Should().Throw() - .WithMessage("*Key*"); + var ex = Assert.Throws(act); + Assert.IsTrue(ex.Message.Contains("Key", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -200,8 +199,8 @@ public void Throws_When_TripleDes_Missing_IV() } }; Action act = () => InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - act.Should().Throw() - .WithMessage("*IV*"); + var ex = Assert.Throws(act); + Assert.IsTrue(ex.Message.Contains("IV", StringComparison.OrdinalIgnoreCase)); } [TestMethod] @@ -213,7 +212,7 @@ public void Returns_Null_When_Json_Options_Empty() Interceptors = new DashboardInterceptorOptions() }; var result = InterceptorConfigurationBuilder.Resolve(queueOptions, EmptyProfiles); - result.Should().BeNull(); + Assert.IsNull(result); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConnectionsControllerTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConnectionsControllerTests.cs index 0c937cad..7c775a0b 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConnectionsControllerTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConnectionsControllerTests.cs @@ -1,10 +1,10 @@ using System; +using System.Linq; using System.Collections.Generic; using System.Threading.Tasks; using DotNetWorkQueue.Dashboard.Api.Controllers; using DotNetWorkQueue.Dashboard.Api.Models; using DotNetWorkQueue.Dashboard.Api.Services; -using FluentAssertions; using Microsoft.AspNetCore.Mvc; using NSubstitute; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -23,7 +23,7 @@ public void GetConnections_Returns_Ok_With_List() var result = controller.GetConnections(); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -39,9 +39,9 @@ public void GetConnections_Returns_Populated_List() var result = controller.GetConnections() as OkObjectResult; - result.Should().NotBeNull(); + Assert.IsNotNull(result); var items = result.Value as IReadOnlyList; - items.Should().HaveCount(1); + Assert.AreEqual(1, (items).Count()); } [TestMethod] @@ -54,7 +54,7 @@ public void GetQueues_Returns_Ok_With_List() var result = controller.GetQueues(connectionId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -80,7 +80,7 @@ public async Task GetJobs_Returns_Ok() var result = await controller.GetJobs(connectionId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConsumersControllerTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConsumersControllerTests.cs index f961c440..72c6f396 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConsumersControllerTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/ConsumersControllerTests.cs @@ -1,10 +1,10 @@ using System; +using System.Linq; using System.Collections.Generic; using DotNetWorkQueue.Dashboard.Api.Configuration; using DotNetWorkQueue.Dashboard.Api.Controllers; using DotNetWorkQueue.Dashboard.Api.Models; using DotNetWorkQueue.Dashboard.Api.Services; -using FluentAssertions; using Microsoft.AspNetCore.Mvc; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; @@ -40,10 +40,12 @@ public void Register_Returns_201_With_ConsumerId() FriendlyName = "test" }); - var objectResult = result.Should().BeOfType().Subject; - objectResult.StatusCode.Should().Be(201); - var response = objectResult.Value.Should().BeOfType().Subject; - response.ConsumerId.Should().Be(consumerId); + Assert.IsInstanceOfType(result); + var objectResult = (ObjectResult)result; + Assert.AreEqual(201, objectResult.StatusCode); + Assert.IsInstanceOfType(objectResult.Value); + var response = (ConsumerRegistrationResponse)objectResult.Value; + Assert.AreEqual(consumerId, response.ConsumerId); } [TestMethod] @@ -56,7 +58,7 @@ public void Register_Returns_NotFound_When_Tracking_Disabled() QueueName = "q", MachineName = "M", ProcessId = 1 }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -72,7 +74,7 @@ public void Register_Response_Includes_HeartbeatInterval() }) as ObjectResult; var response = result!.Value as ConsumerRegistrationResponse; - response!.HeartbeatIntervalSeconds.Should().Be(45); + Assert.AreEqual(45, response!.HeartbeatIntervalSeconds); } // === Heartbeat === @@ -86,7 +88,7 @@ public void Heartbeat_Returns_NoContent_When_Found() var result = controller.Heartbeat(new ConsumerHeartbeatRequest { ConsumerId = id }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -97,7 +99,7 @@ public void Heartbeat_Returns_NotFound_When_Unknown() var result = controller.Heartbeat(new ConsumerHeartbeatRequest { ConsumerId = Guid.NewGuid() }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -116,7 +118,7 @@ public void Heartbeat_Passes_Metrics_To_Registry() PoisonMessages = 1 }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); registry.Received(1).Heartbeat(id, 100, 5, 3, 1); } @@ -127,7 +129,7 @@ public void Heartbeat_Returns_NotFound_When_Tracking_Disabled() var result = controller.Heartbeat(new ConsumerHeartbeatRequest { ConsumerId = Guid.NewGuid() }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } // === Unregister === @@ -141,7 +143,7 @@ public void Unregister_Returns_NoContent_When_Found() var result = controller.Unregister(id); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -152,7 +154,7 @@ public void Unregister_Returns_NotFound_When_Unknown() var result = controller.Unregister(Guid.NewGuid()); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -162,7 +164,7 @@ public void Unregister_Returns_NotFound_When_Tracking_Disabled() var result = controller.Unregister(Guid.NewGuid()); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } // === GetConsumers === @@ -178,9 +180,9 @@ public void GetConsumers_Returns_Ok_With_All() var result = controller.GetConsumers() as OkObjectResult; - result.Should().NotBeNull(); + Assert.IsNotNull(result); var items = result!.Value as List; - items.Should().HaveCount(1); + Assert.AreEqual(1, (items).Count()); } [TestMethod] @@ -202,11 +204,11 @@ public void GetConsumers_Returns_Metrics_In_Response() var result = controller.GetConsumers() as OkObjectResult; var items = result!.Value as List; - items.Should().HaveCount(1); - items![0].MessagesProcessed.Should().Be(500); - items[0].MessagesErrored.Should().Be(10); - items[0].MessagesRolledBack.Should().Be(7); - items[0].PoisonMessages.Should().Be(2); + Assert.AreEqual(1, (items).Count()); + Assert.AreEqual(500, items![0].MessagesProcessed); + Assert.AreEqual(10, items[0].MessagesErrored); + Assert.AreEqual(7, items[0].MessagesRolledBack); + Assert.AreEqual(2, items[0].PoisonMessages); } [TestMethod] @@ -229,9 +231,9 @@ public void GetConsumers_Returns_Empty_When_Tracking_Disabled() var result = controller.GetConsumers() as OkObjectResult; - result.Should().NotBeNull(); + Assert.IsNotNull(result); var items = result!.Value as ConsumerInfoResponse[]; - items.Should().BeEmpty(); + Assert.IsFalse((items).Any()); } // === GetConsumerCounts === @@ -245,10 +247,10 @@ public void GetConsumerCounts_Returns_Ok_With_Dictionary() var result = controller.GetConsumerCounts() as OkObjectResult; - result.Should().NotBeNull(); + Assert.IsNotNull(result); var counts = result!.Value as Dictionary; - counts.Should().ContainKey(queueId); - counts![queueId].Should().Be(3); + Assert.IsTrue((counts).ContainsKey(queueId)); + Assert.AreEqual(3, counts![queueId]); } [TestMethod] @@ -258,9 +260,9 @@ public void GetConsumerCounts_Returns_Empty_When_Tracking_Disabled() var result = controller.GetConsumerCounts() as OkObjectResult; - result.Should().NotBeNull(); + Assert.IsNotNull(result); var counts = result!.Value as Dictionary; - counts.Should().BeEmpty(); + Assert.IsFalse((counts).Any()); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/QueuesControllerTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/QueuesControllerTests.cs index 421fe96e..29d8113e 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/QueuesControllerTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Controllers/QueuesControllerTests.cs @@ -4,7 +4,6 @@ using DotNetWorkQueue.Dashboard.Api.Controllers; using DotNetWorkQueue.Dashboard.Api.Models; using DotNetWorkQueue.Dashboard.Api.Services; -using FluentAssertions; using Microsoft.AspNetCore.Mvc; using NSubstitute; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -27,9 +26,9 @@ public async Task GetStatus_Returns_Ok() var result = await controller.GetStatus(queueId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); var okResult = (OkObjectResult)result; - ((QueueStatusResponse)okResult.Value).Total.Should().Be(17); + Assert.AreEqual(17, ((QueueStatusResponse)okResult.Value).Total); } [TestMethod] @@ -42,7 +41,7 @@ public void GetFeatures_Returns_Ok() var result = controller.GetFeatures(queueId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -71,8 +70,8 @@ public async Task GetMessageCount_Returns_Ok() var result = await controller.GetMessageCount(queueId); - result.Should().BeOfType(); - ((OkObjectResult)result).Value.Should().Be(42L); + Assert.IsInstanceOfType(result); + Assert.AreEqual(42L, ((OkObjectResult)result).Value); } [TestMethod] @@ -85,7 +84,7 @@ public async Task GetMessageDetail_Returns_Ok_When_Found() var result = await controller.GetMessageDetail(queueId, "1"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -98,7 +97,7 @@ public async Task GetMessageDetail_Returns_NotFound_When_Null() var result = await controller.GetMessageDetail(queueId, "999"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -130,7 +129,7 @@ public async Task GetErrors_Returns_Ok() var result = await controller.GetErrors(queueId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -143,7 +142,7 @@ public async Task GetErrorRetries_Returns_Ok() var result = await controller.GetErrorRetries(queueId, "1"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -156,7 +155,7 @@ public async Task GetConfiguration_Returns_Ok() var result = await controller.GetConfiguration(queueId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -167,7 +166,7 @@ public async Task GetMessages_Returns_BadRequest_For_Invalid_Status() var result = await controller.GetMessages(Guid.NewGuid(), status: 99); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -183,7 +182,7 @@ public async Task GetMessages_Accepts_Valid_Status() var result = await controller.GetMessages(queueId, status: 0); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -194,7 +193,7 @@ public async Task GetMessageCount_Returns_BadRequest_For_Invalid_Status() var result = await controller.GetMessageCount(Guid.NewGuid(), status: 99); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -210,7 +209,7 @@ public async Task GetMessages_Accepts_Null_Status() var result = await controller.GetMessages(queueId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -226,7 +225,7 @@ public async Task GetMessageBody_Returns_Ok() var result = await controller.GetMessageBody(queueId, "1"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -239,7 +238,7 @@ public async Task GetMessageBody_Returns_NotFound() var result = await controller.GetMessageBody(queueId, "999"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -255,7 +254,7 @@ public async Task GetMessageHeaders_Returns_Ok() var result = await controller.GetMessageHeaders(queueId, "1"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -268,7 +267,7 @@ public async Task GetMessageHeaders_Returns_NotFound() var result = await controller.GetMessageHeaders(queueId, "999"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -281,7 +280,7 @@ public async Task DeleteMessage_Returns_NoContent_When_Found() var result = await controller.DeleteMessage(queueId, "1"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -294,7 +293,7 @@ public async Task DeleteMessage_Returns_NotFound_When_Not_Found() var result = await controller.DeleteMessage(queueId, "999"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -307,9 +306,9 @@ public async Task DeleteAllErrors_Returns_Deleted_Count() var result = await controller.DeleteAllErrors(queueId); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); var ok = (OkObjectResult)result; - ((DeleteAllResponse)ok.Value).Deleted.Should().Be(5L); + Assert.AreEqual(5L, ((DeleteAllResponse)ok.Value).Deleted); } [TestMethod] @@ -322,7 +321,7 @@ public async Task RequeueErrorMessage_Returns_NoContent_When_Found() var result = await controller.RequeueErrorMessage(queueId, "1"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -335,7 +334,7 @@ public async Task RequeueErrorMessage_Returns_NotFound_When_Not_Found() var result = await controller.RequeueErrorMessage(queueId, "999"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -348,7 +347,7 @@ public async Task ResetStaleMessage_Returns_NoContent_When_Reset() var result = await controller.ResetStaleMessage(queueId, "1"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -361,7 +360,7 @@ public async Task ResetStaleMessage_Returns_NotFound_When_Not_In_Processing() var result = await controller.ResetStaleMessage(queueId, "999"); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -372,7 +371,7 @@ public async Task EditMessageBody_Returns_BadRequest_When_Body_Is_Null() var result = await controller.EditMessageBody(Guid.NewGuid(), "1", new EditMessageBodyRequest { Body = null }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -385,7 +384,7 @@ public async Task EditMessageBody_Returns_NoContent_On_Success() var result = await controller.EditMessageBody(queueId, "1", new EditMessageBodyRequest { Body = "{}" }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -398,7 +397,7 @@ public async Task EditMessageBody_Returns_NotFound_When_Message_Not_Found() var result = await controller.EditMessageBody(queueId, "999", new EditMessageBodyRequest { Body = "{}" }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -411,7 +410,7 @@ public async Task EditMessageBody_Returns_BadRequest_When_TypeUnresolvable() var result = await controller.EditMessageBody(queueId, "1", new EditMessageBodyRequest { Body = "{}" }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -424,7 +423,7 @@ public async Task EditMessageBody_Returns_Conflict_When_Message_Being_Processed( var result = await controller.EditMessageBody(queueId, "1", new EditMessageBodyRequest { Body = "{}" }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } [TestMethod] @@ -437,7 +436,7 @@ public async Task EditMessageBody_Returns_BadRequest_When_Invalid_Json() var result = await controller.EditMessageBody(queueId, "1", new EditMessageBodyRequest { Body = "{invalid}" }); - result.Should().BeOfType(); + Assert.IsInstanceOfType(result); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/DashboardApiTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/DashboardApiTests.cs index 1ec0f410..e9f99ea7 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/DashboardApiTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/DashboardApiTests.cs @@ -1,6 +1,6 @@ using System; +using System.Linq; using DotNetWorkQueue.Dashboard.Api.Configuration; -using FluentAssertions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -16,7 +16,7 @@ public void Connections_Empty_When_No_Registrations() var options = new DashboardOptions(); using var api = new DashboardApi(options, NullLogger.Instance); - api.Connections.Should().BeEmpty(); + Assert.IsFalse((api.Connections).Any()); } [TestMethod] @@ -27,7 +27,7 @@ public void FindQueue_Returns_Null_For_Unknown_Id() var result = api.FindQueue(Guid.NewGuid()); - result.Should().BeNull(); + Assert.IsNull(result); } [TestMethod] @@ -38,7 +38,7 @@ public void GetQueueContainer_Throws_For_Unknown_Id() var act = () => api.GetQueueContainer(Guid.NewGuid()); - act.Should().Throw(); + Assert.Throws(act); } [TestMethod] @@ -60,7 +60,7 @@ public void FindQueue_Throws_After_Dispose() var act = () => api.FindQueue(Guid.NewGuid()); - act.Should().Throw(); + Assert.Throws(act); } [TestMethod] @@ -72,7 +72,7 @@ public void GetQueueContainer_Throws_After_Dispose() var act = () => api.GetQueueContainer(Guid.NewGuid()); - act.Should().Throw(); + Assert.Throws(act); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/DotNetWorkQueue.Dashboard.Api.Tests.csproj b/Source/DotNetWorkQueue.Dashboard.Api.Tests/DotNetWorkQueue.Dashboard.Api.Tests.csproj index 95b0bdbc..67afb857 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/DotNetWorkQueue.Dashboard.Api.Tests.csproj +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/DotNetWorkQueue.Dashboard.Api.Tests.csproj @@ -24,7 +24,6 @@ - diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsCorsAndAuthTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsCorsAndAuthTests.cs index 3a5c5f77..b9c7c286 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsCorsAndAuthTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsCorsAndAuthTests.cs @@ -23,7 +23,6 @@ using DotNetWorkQueue.Dashboard.Api; using DotNetWorkQueue.Dashboard.Api.Configuration; using DotNetWorkQueue.Dashboard.Api.Controllers; -using FluentAssertions; using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationModels; @@ -54,8 +53,8 @@ public void AddDotNetWorkQueueDashboard_Registers_CorsPolicy_When_Enabled_With_O var corsOptions = provider.GetRequiredService>().Value; var policy = corsOptions.GetPolicy("DashboardCors"); - policy.Should().NotBeNull(); - policy!.Origins.Should().BeEquivalentTo(new[] { "https://example.com", "https://localhost:5001" }); + Assert.IsNotNull(policy); + CollectionAssert.AreEquivalent((System.Collections.ICollection)new[] { "https://example.com", "https://localhost:5001" }, (System.Collections.ICollection)(policy!.Origins)); } [TestMethod] @@ -75,7 +74,7 @@ public void AddDotNetWorkQueueDashboard_Does_Not_Register_CorsPolicy_When_Origin var corsOptions = provider.GetService>(); if (corsOptions != null) - corsOptions.Value.GetPolicy("DashboardCors").Should().BeNull(); + Assert.IsNull(corsOptions.Value.GetPolicy("DashboardCors")); } // Note: the "DashboardExtensions adds DashboardAuthorizationConvention when @@ -97,7 +96,7 @@ public void DashboardAuthorizationConvention_Apply_Adds_AuthorizeFilter_To_Dashb convention.Apply(controllerModel); - controllerModel.Filters.OfType().Should().HaveCount(1); + Assert.AreEqual(1, (controllerModel.Filters.OfType()).Count()); } [TestMethod] @@ -111,7 +110,7 @@ public void DashboardAuthorizationConvention_Apply_Ignores_Controller_From_Other convention.Apply(controllerModel); - controllerModel.Filters.Should().BeEmpty(); + Assert.IsFalse((controllerModel.Filters).Any()); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsFromConfigurationTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsFromConfigurationTests.cs index df5bf89d..1495351a 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsFromConfigurationTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsFromConfigurationTests.cs @@ -17,10 +17,10 @@ //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // --------------------------------------------------------------------- using System; +using System.Linq; using System.Collections.Generic; using DotNetWorkQueue.Dashboard.Api; using DotNetWorkQueue.Dashboard.Api.Configuration; -using FluentAssertions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -51,8 +51,8 @@ public void AddDotNetWorkQueueDashboard_FromConfiguration_Memory_RegistersConnec var provider = services.BuildServiceProvider(); var options = provider.GetRequiredService(); - options.EnableSwagger.Should().BeFalse(); - options.ConnectionRegistrations.Should().NotBeEmpty(); + Assert.IsFalse(options.EnableSwagger); + Assert.IsTrue((options.ConnectionRegistrations).Any()); } // Task 2: Parameterized test over all 5 valid transport names @@ -82,7 +82,7 @@ public void AddDotNetWorkQueueDashboard_FromConfiguration_AllTransports_Register var provider = services.BuildServiceProvider(); var options = provider.GetRequiredService(); - options.ConnectionRegistrations.Should().NotBeEmpty(); + Assert.IsTrue((options.ConnectionRegistrations).Any()); } // Task 2: Unknown-transport error test @@ -122,7 +122,7 @@ public void AddDotNetWorkQueueDashboard_FromConfiguration_MissingTransport_Throw var ex = Assert.ThrowsExactly(() => services.AddDotNetWorkQueueDashboard(config.GetSection("Dashboard"))); - ex.Message.Should().Contain("Transport"); + StringAssert.Contains(ex.Message, "Transport"); } // Task 3: Missing-ConnectionString error test @@ -144,7 +144,7 @@ public void AddDotNetWorkQueueDashboard_FromConfiguration_MissingConnectionStrin var ex = Assert.ThrowsExactly(() => services.AddDotNetWorkQueueDashboard(config.GetSection("Dashboard"))); - ex.Message.Should().Contain("ConnectionString"); + StringAssert.Contains(ex.Message, "ConnectionString"); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsSwaggerTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsSwaggerTests.cs index f8d97708..a3b9adfa 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsSwaggerTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsSwaggerTests.cs @@ -17,7 +17,6 @@ //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // --------------------------------------------------------------------- using DotNetWorkQueue.Dashboard.Api; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.OpenApi; @@ -45,8 +44,8 @@ public void AddDotNetWorkQueueDashboard_Registers_SwaggerServices_When_Enabled() .GetRequiredService>() .Value; - swaggerOptions.SwaggerGeneratorOptions.SwaggerDocs.Should().ContainKey("v1"); - swaggerOptions.SwaggerGeneratorOptions.SwaggerDocs["v1"].Title.Should().Be("DotNetWorkQueue Dashboard"); + Assert.IsTrue((swaggerOptions.SwaggerGeneratorOptions.SwaggerDocs).ContainsKey("v1")); + Assert.AreEqual("DotNetWorkQueue Dashboard", swaggerOptions.SwaggerGeneratorOptions.SwaggerDocs["v1"].Title); } [TestMethod] @@ -66,11 +65,11 @@ public void AddDotNetWorkQueueDashboard_Registers_ApiKeySecurityScheme_When_ApiK .GetRequiredService>() .Value; - swaggerOptions.SwaggerGeneratorOptions.SecuritySchemes.Should().ContainKey("ApiKey"); + Assert.IsTrue((swaggerOptions.SwaggerGeneratorOptions.SecuritySchemes).ContainsKey("ApiKey")); var scheme = swaggerOptions.SwaggerGeneratorOptions.SecuritySchemes["ApiKey"]; - scheme.Type.Should().Be(SecuritySchemeType.ApiKey); - scheme.In.Should().Be(ParameterLocation.Header); - scheme.Name.Should().Be("X-Api-Key"); + Assert.AreEqual(SecuritySchemeType.ApiKey, scheme.Type); + Assert.AreEqual(ParameterLocation.Header, scheme.In); + Assert.AreEqual("X-Api-Key", scheme.Name); } [TestMethod] @@ -90,7 +89,7 @@ public void AddDotNetWorkQueueDashboard_Does_Not_Register_ApiKeySecurityScheme_W .GetRequiredService>() .Value; - swaggerOptions.SwaggerGeneratorOptions.SecuritySchemes.Should().NotContainKey("ApiKey"); + Assert.IsFalse((swaggerOptions.SwaggerGeneratorOptions.SecuritySchemes).ContainsKey("ApiKey")); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsTests.cs index acf979e8..e6a791e1 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Extensions/DashboardExtensionsTests.cs @@ -5,7 +5,6 @@ using DotNetWorkQueue.Dashboard.Api; using DotNetWorkQueue.Dashboard.Api.Configuration; using DotNetWorkQueue.Dashboard.Api.Services; -using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -167,8 +166,8 @@ public void AddDotNetWorkQueueDashboard_PreloadsAssemblies_From_AssemblyPaths() { // Use Newtonsoft.Json as a test DLL — it's in our bin but let's verify // the preload path works by copying it and checking it loads from there - var sourceDll = Path.Combine(AppContext.BaseDirectory, "FluentAssertions.dll"); - var destDll = Path.Combine(pluginDir, "FluentAssertions.dll"); + var sourceDll = Path.Combine(AppContext.BaseDirectory, "Newtonsoft.Json.dll"); + var destDll = Path.Combine(pluginDir, "Newtonsoft.Json.dll"); File.Copy(sourceDll, destDll); var services = new ServiceCollection(); @@ -183,7 +182,8 @@ public void AddDotNetWorkQueueDashboard_PreloadsAssemblies_From_AssemblyPaths() // If PreloadAssemblies threw, we wouldn't get here var provider = services.BuildServiceProvider(); var opts = provider.GetRequiredService(); - opts.AssemblyPaths.Should().ContainSingle().Which.Should().Be(pluginDir); + Assert.AreEqual(1, (opts.AssemblyPaths).Count()); + Assert.AreEqual(pluginDir, (opts.AssemblyPaths).Single()); } finally { @@ -205,7 +205,7 @@ public void AddDotNetWorkQueueDashboard_PreloadAssemblies_Ignores_NonexistentDir }); var provider = services.BuildServiceProvider(); - provider.GetRequiredService().Should().NotBeNull(); + Assert.IsNotNull(provider.GetRequiredService()); } [TestMethod] @@ -229,7 +229,7 @@ public void AddDotNetWorkQueueDashboard_PreloadAssemblies_Ignores_InvalidDlls() }); var provider = services.BuildServiceProvider(); - provider.GetRequiredService().Should().NotBeNull(); + Assert.IsNotNull(provider.GetRequiredService()); } finally { diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/ApiKeyAuthorizationFilterTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/ApiKeyAuthorizationFilterTests.cs index f2d874a9..a0d62b79 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/ApiKeyAuthorizationFilterTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/ApiKeyAuthorizationFilterTests.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using DotNetWorkQueue.Dashboard.Api.Configuration; using DotNetWorkQueue.Dashboard.Api.Middleware; -using FluentAssertions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Abstractions; @@ -23,7 +22,7 @@ public void OnAuthorization_When_No_ApiKey_Configured_Allows_Request() filter.OnAuthorization(context); - context.Result.Should().BeNull(); + Assert.IsNull(context.Result); } [TestMethod] @@ -35,7 +34,7 @@ public void OnAuthorization_When_Valid_ApiKey_Allows_Request() filter.OnAuthorization(context); - context.Result.Should().BeNull(); + Assert.IsNull(context.Result); } [TestMethod] @@ -47,7 +46,7 @@ public void OnAuthorization_When_Invalid_ApiKey_Returns_Unauthorized() filter.OnAuthorization(context); - context.Result.Should().BeOfType(); + Assert.IsInstanceOfType(context.Result); } [TestMethod] @@ -59,7 +58,7 @@ public void OnAuthorization_When_Missing_Header_Returns_Unauthorized() filter.OnAuthorization(context); - context.Result.Should().BeOfType(); + Assert.IsInstanceOfType(context.Result); } private static AuthorizationFilterContext CreateContext(string apiKeyHeaderValue = null) diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/DashboardExceptionFilterTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/DashboardExceptionFilterTests.cs index c65e5edf..bfb2c944 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/DashboardExceptionFilterTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Middleware/DashboardExceptionFilterTests.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using DotNetWorkQueue.Dashboard.Api.Middleware; -using FluentAssertions; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Abstractions; @@ -27,11 +26,11 @@ public void InvalidOperationException_In_Development_Returns_Detailed_Message() filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(404); - GetErrorMessage(result).Should().Be("Queue not found"); + Assert.IsNotNull(result); + Assert.AreEqual(404, result.StatusCode); + Assert.AreEqual("Queue not found", GetErrorMessage(result)); } [TestMethod] @@ -42,11 +41,11 @@ public void InvalidOperationException_In_Production_Returns_Generic_Message() filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(404); - GetErrorMessage(result).Should().Be("An internal error occurred"); + Assert.IsNotNull(result); + Assert.AreEqual(404, result.StatusCode); + Assert.AreEqual("An internal error occurred", GetErrorMessage(result)); } [TestMethod] @@ -57,11 +56,11 @@ public void NotSupportedException_In_Development_Returns_Detailed_Message() filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(501); - GetErrorMessage(result).Should().Be("Feature not available"); + Assert.IsNotNull(result); + Assert.AreEqual(501, result.StatusCode); + Assert.AreEqual("Feature not available", GetErrorMessage(result)); } [TestMethod] @@ -72,11 +71,11 @@ public void NotSupportedException_In_Production_Returns_Generic_Message() filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(501); - GetErrorMessage(result).Should().Be("An internal error occurred"); + Assert.IsNotNull(result); + Assert.AreEqual(501, result.StatusCode); + Assert.AreEqual("An internal error occurred", GetErrorMessage(result)); } [TestMethod] @@ -87,11 +86,11 @@ public void ObjectDisposedException_Always_Returns_Service_Unavailable() filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(503); - GetErrorMessage(result).Should().Be("Service unavailable"); + Assert.IsNotNull(result); + Assert.AreEqual(503, result.StatusCode); + Assert.AreEqual("Service unavailable", GetErrorMessage(result)); } [TestMethod] @@ -102,11 +101,11 @@ public void ObjectDisposedException_In_Development_Also_Returns_Service_Unavaila filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(503); - GetErrorMessage(result).Should().Be("Service unavailable"); + Assert.IsNotNull(result); + Assert.AreEqual(503, result.StatusCode); + Assert.AreEqual("Service unavailable", GetErrorMessage(result)); } [TestMethod] @@ -117,11 +116,11 @@ public void UnhandledException_In_Production_Returns_Generic_500() filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(500); - GetErrorMessage(result).Should().Be("An internal error occurred"); + Assert.IsNotNull(result); + Assert.AreEqual(500, result.StatusCode); + Assert.AreEqual("An internal error occurred", GetErrorMessage(result)); } [TestMethod] @@ -132,11 +131,11 @@ public void UnhandledException_In_Development_Returns_Detailed_500() filter.OnException(context); - context.ExceptionHandled.Should().BeTrue(); + Assert.IsTrue(context.ExceptionHandled); var result = context.Result as ObjectResult; - result.Should().NotBeNull(); - result.StatusCode.Should().Be(500); - GetErrorMessage(result).Should().Be("Something unexpected"); + Assert.IsNotNull(result); + Assert.AreEqual(500, result.StatusCode); + Assert.AreEqual("Something unexpected", GetErrorMessage(result)); } private static DashboardExceptionFilter CreateFilter(string environmentName) diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/BulkActionResponseTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/BulkActionResponseTests.cs index a24e196a..8beb5541 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/BulkActionResponseTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/BulkActionResponseTests.cs @@ -1,5 +1,4 @@ using DotNetWorkQueue.Dashboard.Api.Models; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Models @@ -11,14 +10,14 @@ public class BulkActionResponseTests public void Count_Can_Be_Set_And_Read() { var sut = new BulkActionResponse { Count = 150L }; - sut.Count.Should().Be(150L); + Assert.AreEqual(150L, sut.Count); } [TestMethod] public void Count_Defaults_To_Zero() { var sut = new BulkActionResponse(); - sut.Count.Should().Be(0L); + Assert.AreEqual(0L, sut.Count); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/DashboardSettingsResponseTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/DashboardSettingsResponseTests.cs index add697ef..a76f0631 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/DashboardSettingsResponseTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/DashboardSettingsResponseTests.cs @@ -1,5 +1,4 @@ using DotNetWorkQueue.Dashboard.Api.Models; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Models @@ -11,14 +10,14 @@ public class DashboardSettingsResponseTests public void ReadOnly_Can_Be_Set_And_Read() { var sut = new DashboardSettingsResponse { ReadOnly = true }; - sut.ReadOnly.Should().BeTrue(); + Assert.IsTrue(sut.ReadOnly); } [TestMethod] public void ReadOnly_Defaults_To_False() { var sut = new DashboardSettingsResponse(); - sut.ReadOnly.Should().BeFalse(); + Assert.IsFalse(sut.ReadOnly); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/ErrorRetryResponseTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/ErrorRetryResponseTests.cs index 268a65ab..9055051a 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/ErrorRetryResponseTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/ErrorRetryResponseTests.cs @@ -1,5 +1,4 @@ using DotNetWorkQueue.Dashboard.Api.Models; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Models @@ -18,10 +17,10 @@ public void All_Properties_Can_Be_Set_And_Read() RetryCount = 5 }; - sut.ErrorTrackingId.Should().Be(42L); - sut.QueueId.Should().Be("msg-789"); - sut.ExceptionType.Should().Be("System.InvalidOperationException"); - sut.RetryCount.Should().Be(5); + Assert.AreEqual(42L, sut.ErrorTrackingId); + Assert.AreEqual("msg-789", sut.QueueId); + Assert.AreEqual("System.InvalidOperationException", sut.ExceptionType); + Assert.AreEqual(5, sut.RetryCount); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/HistoryResponseTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/HistoryResponseTests.cs index aa7be531..dfeae3e2 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/HistoryResponseTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Models/HistoryResponseTests.cs @@ -1,6 +1,5 @@ using System; using DotNetWorkQueue.Dashboard.Api.Models; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DotNetWorkQueue.Dashboard.Api.Tests.Models @@ -12,21 +11,21 @@ public class HistoryResponseTests public void QueueId_Can_Be_Set_And_Read() { var sut = new HistoryResponse { QueueId = "msg-123" }; - sut.QueueId.Should().Be("msg-123"); + Assert.AreEqual("msg-123", sut.QueueId); } [TestMethod] public void CorrelationId_Can_Be_Set_And_Read() { var sut = new HistoryResponse { CorrelationId = "corr-456" }; - sut.CorrelationId.Should().Be("corr-456"); + Assert.AreEqual("corr-456", sut.CorrelationId); } [TestMethod] public void Status_Can_Be_Set_And_Read() { var sut = new HistoryResponse { Status = 3 }; - sut.Status.Should().Be(3); + Assert.AreEqual(3, sut.Status); } [TestMethod] @@ -34,35 +33,35 @@ public void EnqueuedUtc_Can_Be_Set_And_Read() { var time = new DateTime(2026, 3, 24, 12, 0, 0, DateTimeKind.Utc); var sut = new HistoryResponse { EnqueuedUtc = time }; - sut.EnqueuedUtc.Should().Be(time); + Assert.AreEqual(time, sut.EnqueuedUtc); } [TestMethod] public void DurationMs_Can_Be_Set_And_Read() { var sut = new HistoryResponse { DurationMs = 1500L }; - sut.DurationMs.Should().Be(1500L); + Assert.AreEqual(1500L, sut.DurationMs); } [TestMethod] public void ExceptionText_Can_Be_Set_And_Read() { var sut = new HistoryResponse { ExceptionText = "NullReferenceException" }; - sut.ExceptionText.Should().Be("NullReferenceException"); + Assert.AreEqual("NullReferenceException", sut.ExceptionText); } [TestMethod] public void RetryCount_Can_Be_Set_And_Read() { var sut = new HistoryResponse { RetryCount = 3 }; - sut.RetryCount.Should().Be(3); + Assert.AreEqual(3, sut.RetryCount); } [TestMethod] public void Route_Can_Be_Set_And_Read() { var sut = new HistoryResponse { Route = "high-priority" }; - sut.Route.Should().Be("high-priority"); + Assert.AreEqual("high-priority", sut.Route); } [TestMethod] @@ -87,17 +86,17 @@ public void All_Properties_Round_Trip() MessageType = "MyApp.Commands.DoWork" }; - sut.QueueId.Should().Be("q-1"); - sut.CorrelationId.Should().Be("c-1"); - sut.Status.Should().Be(2); - sut.EnqueuedUtc.Should().Be(enqueued); - sut.StartedUtc.Should().Be(started); - sut.CompletedUtc.Should().Be(completed); - sut.DurationMs.Should().Be(1000L); - sut.ExceptionText.Should().BeNull(); - sut.RetryCount.Should().Be(0); - sut.Route.Should().Be("default"); - sut.MessageType.Should().Be("MyApp.Commands.DoWork"); + Assert.AreEqual("q-1", sut.QueueId); + Assert.AreEqual("c-1", sut.CorrelationId); + Assert.AreEqual(2, sut.Status); + Assert.AreEqual(enqueued, sut.EnqueuedUtc); + Assert.AreEqual(started, sut.StartedUtc); + Assert.AreEqual(completed, sut.CompletedUtc); + Assert.AreEqual(1000L, sut.DurationMs); + Assert.IsNull(sut.ExceptionText); + Assert.AreEqual(0, sut.RetryCount); + Assert.AreEqual("default", sut.Route); + Assert.AreEqual("MyApp.Commands.DoWork", sut.MessageType); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/ConsumerRegistryTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/ConsumerRegistryTests.cs index 5ccdb7e8..87e4f50c 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/ConsumerRegistryTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/ConsumerRegistryTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using DotNetWorkQueue.Dashboard.Api.Services; -using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; @@ -43,7 +42,7 @@ public void Register_Returns_NonEmpty_Guid() { var registry = CreateRegistry(out _); var id = registry.Register("testQueue", "MACHINE1", 1234, null); - id.Should().NotBeEmpty(); + Assert.AreNotEqual(Guid.Empty, id); } [TestMethod] @@ -52,7 +51,7 @@ public void Register_Multiple_Returns_Unique_Ids() var registry = CreateRegistry(out _); var id1 = registry.Register("testQueue", "MACHINE1", 1234, null); var id2 = registry.Register("testQueue", "MACHINE1", 5678, null); - id1.Should().NotBe(id2); + Assert.AreNotEqual(id2, id1); } [TestMethod] @@ -62,8 +61,8 @@ public void Register_Matches_Queue_By_Name() registry.Register("testQueue", "MACHINE1", 1234, null); var entries = registry.GetAll(); - entries.Should().HaveCount(1); - entries[0].MatchedQueueId.Should().Be(queueId); + Assert.AreEqual(1, (entries).Count()); + Assert.AreEqual(queueId, entries[0].MatchedQueueId); } [TestMethod] @@ -73,7 +72,7 @@ public void Register_No_Match_When_QueueName_Differs() registry.Register("otherQueue", "MACHINE1", 1234, null); var entries = registry.GetAll(); - entries[0].MatchedQueueId.Should().BeNull(); + Assert.IsNull(entries[0].MatchedQueueId); } [TestMethod] @@ -83,7 +82,7 @@ public void Register_Sets_FriendlyName() registry.Register("testQueue", "MACHINE1", 1234, "MyConsumer"); var entries = registry.GetAll(); - entries[0].FriendlyName.Should().Be("MyConsumer"); + Assert.AreEqual("MyConsumer", entries[0].FriendlyName); } [TestMethod] @@ -95,8 +94,10 @@ public void Register_Sets_RegisteredAt_And_LastHeartbeat() var after = DateTimeOffset.UtcNow; var entry = registry.GetAll()[0]; - entry.RegisteredAt.Should().BeOnOrAfter(before).And.BeOnOrBefore(after); - entry.LastHeartbeat.Should().BeOnOrAfter(before).And.BeOnOrBefore(after); + Assert.IsTrue((entry.RegisteredAt) >= (before)); + Assert.IsTrue((entry.RegisteredAt) <= (after)); + Assert.IsTrue((entry.LastHeartbeat) >= (before)); + Assert.IsTrue((entry.LastHeartbeat) <= (after)); } [TestMethod] @@ -109,15 +110,15 @@ public void Heartbeat_Updates_LastHeartbeat() System.Threading.Thread.Sleep(10); var result = registry.Heartbeat(id); - result.Should().BeTrue(); - registry.GetAll()[0].LastHeartbeat.Should().BeAfter(initialHeartbeat); + Assert.IsTrue(result); + Assert.IsTrue((registry.GetAll()[0].LastHeartbeat) > (initialHeartbeat)); } [TestMethod] public void Heartbeat_Returns_False_For_Unknown_Id() { var registry = CreateRegistry(out _); - registry.Heartbeat(Guid.NewGuid()).Should().BeFalse(); + Assert.IsFalse(registry.Heartbeat(Guid.NewGuid())); } [TestMethod] @@ -129,10 +130,10 @@ public void Heartbeat_Updates_Metrics() registry.Heartbeat(id, messagesProcessed: 100, messagesErrored: 5, messagesRolledBack: 3, poisonMessages: 1); var entry = registry.GetAll()[0]; - entry.MessagesProcessed.Should().Be(100); - entry.MessagesErrored.Should().Be(5); - entry.MessagesRolledBack.Should().Be(3); - entry.PoisonMessages.Should().Be(1); + Assert.AreEqual(100, entry.MessagesProcessed); + Assert.AreEqual(5, entry.MessagesErrored); + Assert.AreEqual(3, entry.MessagesRolledBack); + Assert.AreEqual(1, entry.PoisonMessages); } [TestMethod] @@ -145,10 +146,10 @@ public void Heartbeat_Overwrites_Previous_Metrics() registry.Heartbeat(id, messagesProcessed: 200, messagesErrored: 8, messagesRolledBack: 4, poisonMessages: 1); var entry = registry.GetAll()[0]; - entry.MessagesProcessed.Should().Be(200); - entry.MessagesErrored.Should().Be(8); - entry.MessagesRolledBack.Should().Be(4); - entry.PoisonMessages.Should().Be(1); + Assert.AreEqual(200, entry.MessagesProcessed); + Assert.AreEqual(8, entry.MessagesErrored); + Assert.AreEqual(4, entry.MessagesRolledBack); + Assert.AreEqual(1, entry.PoisonMessages); } [TestMethod] @@ -158,10 +159,10 @@ public void Register_Initializes_Metrics_To_Zero() registry.Register("testQueue", "MACHINE1", 1234, null); var entry = registry.GetAll()[0]; - entry.MessagesProcessed.Should().Be(0); - entry.MessagesErrored.Should().Be(0); - entry.MessagesRolledBack.Should().Be(0); - entry.PoisonMessages.Should().Be(0); + Assert.AreEqual(0, entry.MessagesProcessed); + Assert.AreEqual(0, entry.MessagesErrored); + Assert.AreEqual(0, entry.MessagesRolledBack); + Assert.AreEqual(0, entry.PoisonMessages); } [TestMethod] @@ -170,15 +171,15 @@ public void Unregister_Removes_Consumer() var registry = CreateRegistry(out _); var id = registry.Register("testQueue", "MACHINE1", 1234, null); - registry.Unregister(id).Should().BeTrue(); - registry.GetAll().Should().BeEmpty(); + Assert.IsTrue(registry.Unregister(id)); + Assert.IsFalse((registry.GetAll()).Any()); } [TestMethod] public void Unregister_Returns_False_For_Unknown_Id() { var registry = CreateRegistry(out _); - registry.Unregister(Guid.NewGuid()).Should().BeFalse(); + Assert.IsFalse(registry.Unregister(Guid.NewGuid())); } [TestMethod] @@ -188,7 +189,7 @@ public void GetAll_Returns_All_Registered() registry.Register("testQueue", "MACHINE1", 1234, null); registry.Register("testQueue", "MACHINE2", 5678, null); - registry.GetAll().Should().HaveCount(2); + Assert.AreEqual(2, (registry.GetAll()).Count()); } [TestMethod] @@ -199,8 +200,8 @@ public void GetByQueue_Returns_Only_Matched() registry.Register("otherQueue", "MACHINE2", 5678, null); var matched = registry.GetByQueue(queueId); - matched.Should().HaveCount(1); - matched[0].MachineName.Should().Be("MACHINE1"); + Assert.AreEqual(1, (matched).Count()); + Assert.AreEqual("MACHINE1", matched[0].MachineName); } [TestMethod] @@ -209,7 +210,7 @@ public void GetByQueue_Returns_Empty_When_No_Match() var registry = CreateRegistry(out _); registry.Register("testQueue", "MACHINE1", 1234, null); - registry.GetByQueue(Guid.NewGuid()).Should().BeEmpty(); + Assert.IsFalse((registry.GetByQueue(Guid.NewGuid())).Any()); } [TestMethod] @@ -221,8 +222,8 @@ public void GetCountsByQueue_Returns_Counts() registry.Register("otherQueue", "MACHINE3", 9012, null); var counts = registry.GetCountsByQueue(); - counts.Should().ContainKey(queueId); - counts[queueId].Should().Be(2); + Assert.IsTrue((counts).ContainsKey(queueId)); + Assert.AreEqual(2, counts[queueId]); } [TestMethod] @@ -231,7 +232,7 @@ public void GetCountsByQueue_Excludes_Unmatched() var registry = CreateRegistry(out _); registry.Register("unknownQueue", "MACHINE1", 1234, null); - registry.GetCountsByQueue().Should().BeEmpty(); + Assert.IsFalse((registry.GetCountsByQueue()).Any()); } [TestMethod] @@ -242,8 +243,8 @@ public void PruneStale_Removes_Expired_Consumers() // With a zero threshold, everything is stale var pruned = registry.PruneStale(TimeSpan.Zero); - pruned.Should().Be(1); - registry.GetAll().Should().BeEmpty(); + Assert.AreEqual(1, pruned); + Assert.IsFalse((registry.GetAll()).Any()); } [TestMethod] @@ -253,15 +254,15 @@ public void PruneStale_Keeps_Fresh_Consumers() registry.Register("testQueue", "MACHINE1", 1234, null); var pruned = registry.PruneStale(TimeSpan.FromMinutes(5)); - pruned.Should().Be(0); - registry.GetAll().Should().HaveCount(1); + Assert.AreEqual(0, pruned); + Assert.AreEqual(1, (registry.GetAll()).Count()); } [TestMethod] public void PruneStale_Returns_Zero_When_Empty() { var registry = CreateRegistry(out _); - registry.PruneStale(TimeSpan.Zero).Should().Be(0); + Assert.AreEqual(0, registry.PruneStale(TimeSpan.Zero)); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardHealthCheckTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardHealthCheckTests.cs index 46b37f9c..75116f5f 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardHealthCheckTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardHealthCheckTests.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using DotNetWorkQueue.Dashboard.Api.Services; -using FluentAssertions; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.VisualStudio.TestTools.UnitTesting; using NSubstitute; @@ -22,9 +21,9 @@ public async Task CheckHealthAsync_When_Service_Healthy_Returns_Healthy() var result = await check.CheckHealthAsync(new HealthCheckContext()); - result.Status.Should().Be(HealthStatus.Healthy); - result.Data.Should().ContainKey("uptime"); - result.Data.Should().ContainKey("connections"); + Assert.AreEqual(HealthStatus.Healthy, result.Status); + Assert.IsTrue((result.Data).ContainsKey("uptime")); + Assert.IsTrue((result.Data).ContainsKey("connections")); } [TestMethod] @@ -36,8 +35,8 @@ public async Task CheckHealthAsync_When_Service_Disposed_Returns_Unhealthy() var result = await check.CheckHealthAsync(new HealthCheckContext()); - result.Status.Should().Be(HealthStatus.Unhealthy); - result.Description.Should().Contain("disposed"); + Assert.AreEqual(HealthStatus.Unhealthy, result.Status); + StringAssert.Contains(result.Description, "disposed"); } [TestMethod] @@ -49,8 +48,8 @@ public async Task CheckHealthAsync_When_Exception_Returns_Unhealthy() var result = await check.CheckHealthAsync(new HealthCheckContext()); - result.Status.Should().Be(HealthStatus.Unhealthy); - result.Description.Should().Contain("failed"); + Assert.AreEqual(HealthStatus.Unhealthy, result.Status); + StringAssert.Contains(result.Description, "failed"); } } } diff --git a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardServiceTests.cs b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardServiceTests.cs index d6d79a46..9f7af598 100644 --- a/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardServiceTests.cs +++ b/Source/DotNetWorkQueue.Dashboard.Api.Tests/Services/DashboardServiceTests.cs @@ -16,7 +16,6 @@ using DotNetWorkQueue.Transport.Shared.Basic; using DotNetWorkQueue.Transport.Shared.Basic.Command; using DotNetWorkQueue.Transport.Shared.Basic.Query; -using FluentAssertions; using Microsoft.Extensions.Logging.Abstractions; using NSubstitute; using NSubstitute.ExceptionExtensions; @@ -35,9 +34,9 @@ public void GetConnections_Returns_All_Registered_Connections() var result = service.GetConnections(); - result.Should().HaveCount(1); - result[0].DisplayName.Should().Be("Test Connection"); - result[0].QueueCount.Should().Be(1); + Assert.AreEqual(1, (result).Count()); + Assert.AreEqual("Test Connection", result[0].DisplayName); + Assert.AreEqual(1, result[0].QueueCount); } [TestMethod] @@ -48,8 +47,8 @@ public void GetQueues_Returns_Queues_For_Connection() var result = service.GetQueues(connectionId); - result.Should().HaveCount(1); - result[0].QueueName.Should().Be("TestQueue"); + Assert.AreEqual(1, (result).Count()); + Assert.AreEqual("TestQueue", result[0].QueueName); } [TestMethod] @@ -60,7 +59,7 @@ public void GetQueues_Throws_For_Unknown_ConnectionId() var act = () => service.GetQueues(Guid.NewGuid()); - act.Should().Throw(); + Assert.Throws(act); } [TestMethod] @@ -80,10 +79,10 @@ public async Task GetStatus_Returns_StatusCounts() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetStatusAsync(queueId); - result.Waiting.Should().Be(10); - result.Processing.Should().Be(5); - result.Error.Should().Be(2); - result.Total.Should().Be(17); + Assert.AreEqual(10, result.Waiting); + Assert.AreEqual(5, result.Processing); + Assert.AreEqual(2, result.Error); + Assert.AreEqual(17, result.Total); } [TestMethod] @@ -108,10 +107,10 @@ public void GetFeatures_Returns_TransportOptions() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = service.GetFeatures(queueId); - result.EnableStatus.Should().BeTrue(); - result.EnablePriority.Should().BeFalse(); - result.EnableHeartBeat.Should().BeTrue(); - result.EnableStatusTable.Should().BeTrue(); + Assert.IsTrue(result.EnableStatus); + Assert.IsFalse(result.EnablePriority); + Assert.IsTrue(result.EnableHeartBeat); + Assert.IsTrue(result.EnableStatusTable); } [TestMethod] @@ -128,7 +127,7 @@ public async Task GetMessageCount_Calls_Handler() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageCountAsync(queueId, null); - result.Should().Be(42L); + Assert.AreEqual(42L, result); } [TestMethod] @@ -145,7 +144,7 @@ public async Task GetMessageDetail_Returns_Null_When_Not_Found() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageDetailAsync(queueId, "999"); - result.Should().BeNull(); + Assert.IsNull(result); } [TestMethod] @@ -163,7 +162,7 @@ public async Task GetConfiguration_Returns_Utf8_Json() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetConfigurationAsync(queueId); - result.ConfigurationJson.Should().Be("{\"test\":true}"); + Assert.AreEqual("{\"test\":true}", result.ConfigurationJson); } [TestMethod] @@ -185,8 +184,8 @@ public async Task GetJobsByConnection_Returns_Jobs_From_First_Queue() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetJobsByConnectionAsync(connectionId); - result.Should().HaveCount(1); - result[0].JobName.Should().Be("ConnectionJob"); + Assert.AreEqual(1, (result).Count()); + Assert.AreEqual("ConnectionJob", result[0].JobName); } [TestMethod] @@ -210,7 +209,7 @@ public async Task GetJobsByConnection_Returns_Empty_When_No_Queues() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetJobsByConnectionAsync(connectionId); - result.Should().BeEmpty(); + Assert.IsFalse((result).Any()); } [TestMethod] @@ -221,7 +220,7 @@ public async Task GetJobsByConnection_Throws_For_Unknown_ConnectionId() var act = async () => await service.GetJobsByConnectionAsync(Guid.NewGuid()); - await act.Should().ThrowAsync(); + await Assert.ThrowsAsync(act); } private static IDashboardApi CreateApi(out Guid connectionId, out Guid queueId, bool isRelational = false) @@ -301,12 +300,12 @@ public async Task GetMessageBody_Returns_Decoded_Body() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Body.Should().NotBeNullOrEmpty(); - result.TypeName.Should().Be("System.String"); - result.WasIntercepted.Should().BeFalse(); - result.InterceptorChain.Should().BeEmpty(); - result.DecodingError.Should().BeNull(); + Assert.IsNotNull(result); + Assert.IsFalse(string.IsNullOrEmpty(result.Body)); + Assert.AreEqual("System.String", result.TypeName); + Assert.IsFalse(result.WasIntercepted); + Assert.IsFalse((result.InterceptorChain).Any()); + Assert.IsNull(result.DecodingError); } [TestMethod] @@ -323,7 +322,7 @@ public async Task GetMessageBody_Returns_Null_When_Not_Found() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "999"); - result.Should().BeNull(); + Assert.IsNull(result); } [TestMethod] @@ -352,10 +351,10 @@ public async Task GetMessageBody_Returns_Error_When_Decoding_Fails() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Body.Should().BeNull(); - result.DecodingError.Should().Contain("Bad headers"); - result.DecodingError.Should().Contain("Failed to decode message headers"); + Assert.IsNotNull(result); + Assert.IsNull(result.Body); + StringAssert.Contains(result.DecodingError, "Bad headers"); + StringAssert.Contains(result.DecodingError, "Failed to decode message headers"); } [TestMethod] @@ -384,9 +383,9 @@ public async Task GetMessageHeaders_Returns_Decoded_Headers() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageHeadersAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Headers.Should().ContainKey("key"); - result.DecodingError.Should().BeNull(); + Assert.IsNotNull(result); + Assert.IsTrue((result.Headers).ContainsKey("key")); + Assert.IsNull(result.DecodingError); } [TestMethod] @@ -403,7 +402,7 @@ public async Task GetMessageHeaders_Returns_Null_When_Not_Found() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageHeadersAsync(queueId, "999"); - result.Should().BeNull(); + Assert.IsNull(result); } [TestMethod] @@ -431,9 +430,9 @@ public async Task GetMessageHeaders_Returns_Error_When_Decoding_Fails() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageHeadersAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Headers.Should().BeNull(); - result.DecodingError.Should().Be("Corrupt data"); + Assert.IsNotNull(result); + Assert.IsNull(result.Headers); + Assert.AreEqual("Corrupt data", result.DecodingError); } [TestMethod] @@ -454,9 +453,9 @@ public async Task GetMessageBody_Uses_TypeHeader_When_Type_Is_Resolvable() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.DecodingError.Should().BeNull(); - result.TypeName.Should().Be("System.String"); + Assert.IsNotNull(result); + Assert.IsNull(result.DecodingError); + Assert.AreEqual("System.String", result.TypeName); } [TestMethod] @@ -474,11 +473,11 @@ public async Task GetMessageBody_Falls_Back_To_JObject_When_TypeHeader_Not_Resol var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.DecodingError.Should().BeNull(); - result.Body.Should().NotBeNullOrEmpty(); + Assert.IsNotNull(result); + Assert.IsNull(result.DecodingError); + Assert.IsFalse(string.IsNullOrEmpty(result.Body)); // TypeName comes from the header value since the type couldn't be resolved at runtime - result.TypeName.Should().Be("NotReal.Type, NotReal"); + Assert.AreEqual("NotReal.Type, NotReal", result.TypeName); } [TestMethod] @@ -496,9 +495,9 @@ public async Task GetMessageBody_Falls_Back_To_JObject_When_TypeHeader_Absent() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.DecodingError.Should().BeNull(); - result.Body.Should().NotBeNullOrEmpty(); + Assert.IsNotNull(result); + Assert.IsNull(result.DecodingError); + Assert.IsFalse(string.IsNullOrEmpty(result.Body)); } private static IContainer SetupBodyDecodeContainer(Guid queueId, IDashboardApi api, @@ -589,16 +588,16 @@ public async Task GetMessageBody_InterceptorException_Returns_Friendly_Error_Wit var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Body.Should().BeNull(); - result.DecodingError.Should().Contain("TripleDesMessageInterceptor"); - result.DecodingError.Should().Contain("GZipMessageInterceptor"); - result.DecodingError.Should().Contain("Padding is invalid and cannot be removed"); - result.DecodingError.Should().Contain("Verify that the dashboard has the same interceptors configured"); - result.WasIntercepted.Should().BeTrue(); - result.InterceptorChain.Should().HaveCount(2); - result.InterceptorChain.Should().Contain("TripleDesMessageInterceptor"); - result.InterceptorChain.Should().Contain("GZipMessageInterceptor"); + Assert.IsNotNull(result); + Assert.IsNull(result.Body); + StringAssert.Contains(result.DecodingError, "TripleDesMessageInterceptor"); + StringAssert.Contains(result.DecodingError, "GZipMessageInterceptor"); + StringAssert.Contains(result.DecodingError, "Padding is invalid and cannot be removed"); + StringAssert.Contains(result.DecodingError, "Verify that the dashboard has the same interceptors configured"); + Assert.IsTrue(result.WasIntercepted); + Assert.AreEqual(2, (result.InterceptorChain).Count()); + CollectionAssert.Contains((System.Collections.ICollection)result.InterceptorChain, "TripleDesMessageInterceptor"); + CollectionAssert.Contains((System.Collections.ICollection)result.InterceptorChain, "GZipMessageInterceptor"); } [TestMethod] @@ -644,13 +643,13 @@ public async Task GetMessageBody_SerializationException_Returns_Friendly_Error_A var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Body.Should().BeNull(); - result.DecodingError.Should().Contain("assembly"); - result.DecodingError.Should().Contain("Could not load assembly"); - result.DecodingError.Should().Contain("ensure the assembly containing the message type is available"); - result.WasIntercepted.Should().BeFalse(); - result.InterceptorChain.Should().BeEmpty(); + Assert.IsNotNull(result); + Assert.IsNull(result.Body); + StringAssert.Contains(result.DecodingError, "assembly"); + StringAssert.Contains(result.DecodingError, "Could not load assembly"); + StringAssert.Contains(result.DecodingError, "ensure the assembly containing the message type is available"); + Assert.IsFalse(result.WasIntercepted); + Assert.IsFalse((result.InterceptorChain).Any()); } [TestMethod] @@ -696,13 +695,13 @@ public async Task GetMessageBody_GenericException_During_Body_Decode_Includes_In var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Body.Should().BeNull(); - result.DecodingError.Should().Be("Unexpected deserialization failure"); + Assert.IsNotNull(result); + Assert.IsNull(result.Body); + Assert.AreEqual("Unexpected deserialization failure", result.DecodingError); // Even for generic exceptions, interceptor info should be populated since headers parsed OK - result.WasIntercepted.Should().BeTrue(); - result.InterceptorChain.Should().HaveCount(1); - result.InterceptorChain.Should().Contain("GZipMessageInterceptor"); + Assert.IsTrue(result.WasIntercepted); + Assert.AreEqual(1, (result.InterceptorChain).Count()); + CollectionAssert.Contains((System.Collections.ICollection)result.InterceptorChain, "GZipMessageInterceptor"); } [TestMethod] @@ -751,13 +750,13 @@ public async Task GetMessageBody_With_Interceptors_Happy_Path() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.GetMessageBodyAsync(queueId, "42"); - result.Should().NotBeNull(); - result.Body.Should().NotBeNullOrEmpty(); - result.DecodingError.Should().BeNull(); - result.WasIntercepted.Should().BeTrue(); - result.InterceptorChain.Should().HaveCount(2); - result.InterceptorChain.Should().Contain("TripleDesMessageInterceptor"); - result.InterceptorChain.Should().Contain("GZipMessageInterceptor"); + Assert.IsNotNull(result); + Assert.IsFalse(string.IsNullOrEmpty(result.Body)); + Assert.IsNull(result.DecodingError); + Assert.IsTrue(result.WasIntercepted); + Assert.AreEqual(2, (result.InterceptorChain).Count()); + CollectionAssert.Contains((System.Collections.ICollection)result.InterceptorChain, "TripleDesMessageInterceptor"); + CollectionAssert.Contains((System.Collections.ICollection)result.InterceptorChain, "GZipMessageInterceptor"); } [TestMethod] @@ -774,7 +773,7 @@ public async Task DeleteMessageAsync_Returns_True_When_Handler_Returns_Positive( var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.DeleteMessageAsync(queueId, "42"); - result.Should().BeTrue(); + Assert.IsTrue(result); } [TestMethod] @@ -791,7 +790,7 @@ public async Task DeleteMessageAsync_Returns_False_When_Handler_Returns_Zero() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.DeleteMessageAsync(queueId, "999"); - result.Should().BeFalse(); + Assert.IsFalse(result); } [TestMethod] @@ -808,7 +807,7 @@ public async Task DeleteAllErrorMessagesAsync_Returns_Handler_Count() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.DeleteAllErrorMessagesAsync(queueId); - result.Should().Be(7L); + Assert.AreEqual(7L, result); } [TestMethod] @@ -825,7 +824,7 @@ public async Task RequeueErrorMessageAsync_Returns_True_When_Found() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.RequeueErrorMessageAsync(queueId, "42"); - result.Should().BeTrue(); + Assert.IsTrue(result); } [TestMethod] @@ -842,7 +841,7 @@ public async Task RequeueErrorMessageAsync_Returns_False_When_Not_Found() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.RequeueErrorMessageAsync(queueId, "999"); - result.Should().BeFalse(); + Assert.IsFalse(result); } [TestMethod] @@ -859,7 +858,7 @@ public async Task ResetStaleMessageAsync_Returns_True_When_Reset() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.ResetStaleMessageAsync(queueId, "42"); - result.Should().BeTrue(); + Assert.IsTrue(result); } [TestMethod] @@ -876,7 +875,7 @@ public async Task ResetStaleMessageAsync_Returns_False_When_Not_In_Processing() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.ResetStaleMessageAsync(queueId, "999"); - result.Should().BeFalse(); + Assert.IsFalse(result); } [TestMethod] @@ -893,7 +892,7 @@ public async Task EditMessageBodyAsync_Returns_NotFound_When_Body_Query_Returns_ var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.EditMessageBodyAsync(queueId, "999","{}"); - result.Should().Be(EditMessageBodyResult.NotFound); + Assert.AreEqual(EditMessageBodyResult.NotFound, result); } [TestMethod] @@ -911,7 +910,7 @@ public async Task EditMessageBodyAsync_Returns_TypeUnresolvable_When_No_Type_Hea var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.EditMessageBodyAsync(queueId, "42","\"hello\""); - result.Should().Be(EditMessageBodyResult.TypeUnresolvable); + Assert.AreEqual(EditMessageBodyResult.TypeUnresolvable, result); } [TestMethod] @@ -930,7 +929,7 @@ public async Task EditMessageBodyAsync_Returns_MessageBeingProcessed_When_Status var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.EditMessageBodyAsync(queueId, "42","\"hello\""); - result.Should().Be(EditMessageBodyResult.MessageBeingProcessed); + Assert.AreEqual(EditMessageBodyResult.MessageBeingProcessed, result); } [TestMethod] @@ -949,7 +948,7 @@ public async Task EditMessageBodyAsync_Returns_InvalidJson_When_Json_Is_Malforme var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.EditMessageBodyAsync(queueId, "42","{ not valid json"); - result.Should().Be(EditMessageBodyResult.InvalidJson); + Assert.AreEqual(EditMessageBodyResult.InvalidJson, result); } [TestMethod] @@ -968,7 +967,7 @@ public async Task EditMessageBodyAsync_Returns_Success_When_All_Valid() var service = new DashboardService(api, NullLogger.Instance, new DashboardOptions()); var result = await service.EditMessageBodyAsync(queueId, "42","\"hello world\""); - result.Should().Be(EditMessageBodyResult.Success); + Assert.AreEqual(EditMessageBodyResult.Success, result); } ///