diff --git a/tests/Aspire.Hosting.LocalStack.Integration.Tests/EagerLoadedServices/EagerLoadedServicesTests.cs b/tests/Aspire.Hosting.LocalStack.Integration.Tests/EagerLoadedServices/EagerLoadedServicesTests.cs index 8ddb741..c4e79ff 100644 --- a/tests/Aspire.Hosting.LocalStack.Integration.Tests/EagerLoadedServices/EagerLoadedServicesTests.cs +++ b/tests/Aspire.Hosting.LocalStack.Integration.Tests/EagerLoadedServices/EagerLoadedServicesTests.cs @@ -174,9 +174,10 @@ public async Task LocalStack_Should_Handle_Empty_EagerLoadedServices_Like_Lazy_L await Assert.That(servicesNode).IsNotNull(); // Services should not be running by default (lazy loading) - if (servicesNode.ContainsKey("sqs")) + var sqsService = servicesNode["sqs"]; + if (sqsService is not null) { - await Assert.That(servicesNode["sqs"]?.ToString()).IsNotEqualTo("running"); + await Assert.That(sqsService.ToString()).IsNotEqualTo("running"); } } diff --git a/tests/Aspire.Hosting.LocalStack.Unit.Tests/Extensions/LocalStackProjectExtensionsTests.cs b/tests/Aspire.Hosting.LocalStack.Unit.Tests/Extensions/LocalStackProjectExtensionsTests.cs index fbea36c..cb64e2f 100644 --- a/tests/Aspire.Hosting.LocalStack.Unit.Tests/Extensions/LocalStackProjectExtensionsTests.cs +++ b/tests/Aspire.Hosting.LocalStack.Unit.Tests/Extensions/LocalStackProjectExtensionsTests.cs @@ -24,18 +24,19 @@ public async Task WithReference_Should_Return_Builder_When_LocalStack_Is_Null() { const string testProjectResourceName = "test-project"; + IResourceBuilder? resultBuilder = null; + IResourceBuilder? originalBuilder = null; + var (app, projectResource) = TestApplicationBuilder.CreateWithResource(testProjectResourceName, builder => { var projectBuilder = builder.AddProject(testProjectResourceName, TestDataBuilders.GetTestProjectPath()); - var result = projectBuilder.WithReference(localStackBuilder: null); - - // Should return the same builder - if (!ReferenceEquals(result, projectBuilder)) - { - throw new InvalidOperationException("Builder should be the same reference"); - } + originalBuilder = projectBuilder; + resultBuilder = projectBuilder.WithReference(localStackBuilder: null); }); + // Should return the same builder instance + await Assert.That(resultBuilder).IsSameReferenceAs(originalBuilder); + await Assert.That(app.HasResource("localstack")).IsFalse(); await projectResource.ShouldNotHaveLocalStackEnabledAnnotation(); } diff --git a/tests/Aspire.Hosting.LocalStack.Unit.Tests/TestUtilities/LocalStackAssertions.cs b/tests/Aspire.Hosting.LocalStack.Unit.Tests/TestUtilities/LocalStackAssertions.cs index 7fa10cb..9f220e5 100644 --- a/tests/Aspire.Hosting.LocalStack.Unit.Tests/TestUtilities/LocalStackAssertions.cs +++ b/tests/Aspire.Hosting.LocalStack.Unit.Tests/TestUtilities/LocalStackAssertions.cs @@ -54,7 +54,7 @@ public static async Task ShouldHaveLocalStackEnvironmentConfiguration(this Proje { ArgumentNullException.ThrowIfNull(projectResource); ArgumentNullException.ThrowIfNull(expectedLocalStack); -#pragma warning disable MA0015 +#pragma warning disable MA0015 // ArgumentNullException.ThrowIfNull should be preferred over null check ArgumentNullException.ThrowIfNull(expectedLocalStack.Options); #pragma warning restore MA0015