Skip to content

Commit

Permalink
test: Improve EnsureInitializedAsync_ShouldThrowException_WhenProvide…
Browse files Browse the repository at this point in the history
…rDoesNotExist test
  • Loading branch information
arttonoyan committed Oct 14, 2024
1 parent 84dd0e0 commit 572d67b
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public FeatureLifecycleManagerTests()
Api.Instance.SetContext(null);
Api.Instance.ClearHooks();

//_mockApi = Substitute.ForPartsOf<Api>();
//Api.Instance.Returns(_mockApi);

_mockServiceProvider = Substitute.For<IServiceProvider>();

_systemUnderTest = new FeatureLifecycleManager(
Expand Down Expand Up @@ -48,10 +45,11 @@ public async Task EnsureInitializedAsync_ShouldThrowException_WhenProviderDoesNo
// Arrange
_mockServiceProvider.GetService(typeof(FeatureProvider)).Returns(null as FeatureProvider);

// Act & Assert
var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () =>
await _systemUnderTest.EnsureInitializedAsync().ConfigureAwait(false));
// Act
var act = () => _systemUnderTest.EnsureInitializedAsync().AsTask();

// Assert
var exception = await Assert.ThrowsAsync<InvalidOperationException>(act);

Check failure on line 52 in test/OpenFeature.DependencyInjection.Tests/FeatureLifecycleManagerTests.cs

View workflow job for this annotation

GitHub Actions / check-format

Consider calling ConfigureAwait on the awaited task

Check failure on line 52 in test/OpenFeature.DependencyInjection.Tests/FeatureLifecycleManagerTests.cs

View workflow job for this annotation

GitHub Actions / check-format

Consider calling ConfigureAwait on the awaited task
exception.Message.Should().Be("Feature provider is not registered in the service collection.");
}
}

0 comments on commit 572d67b

Please sign in to comment.