public async Task CheckFeature_ShouldReturnFeatureEnabledOrNot() { // Arrange var client = new HttPlaceholderClient(CreateHttpClient(mock => mock .When($"{BaseUrl}ph-api/metadata/features/authentication") .Respond("application/json", FeatureResponse))); // Act var result = await client.CheckFeatureAsync(FeatureFlagType.Authentication); // Assert Assert.IsTrue(result); }
public async Task CheckFeature_ExceptionInRequest_ShouldThrowHttPlaceholderClientException() { // Arrange var client = new HttPlaceholderClient(CreateHttpClient(mock => mock .When($"{BaseUrl}ph-api/metadata/features/authentication") .Respond(HttpStatusCode.BadRequest, "text/plain", "Error occurred!"))); // Act var exception = await Assert.ThrowsExceptionAsync <HttPlaceholderClientException>(() => client.CheckFeatureAsync(FeatureFlagType.Authentication)); // Assert Assert.AreEqual("Status code '400' returned by HttPlaceholder with message 'Error occurred!'", exception.Message); }