public async Task SetValueShouldRaiseOnFeatureUpdated() { // Arrange int calls = 0; InitializeFeaturesData(); var settings = new Settings { OnServerFeatureUpdated = _ => { calls++; } }; var featuresService = new FeaturesService(_db, settings); string newValue = "dark"; // Act var result = await featuresService.SetValue("Theme", newValue); // Assert calls.ShouldBe(1); }
public async Task SetValueShouldFailIfMismatchTypeForStringValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("Theme", true).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature Theme is a string feature..."); }
public async Task SetValueShouldFailIfMismatchTypeForDecimalValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("TaxPercent", "123").ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature TaxPercent is a decimal feature..."); }
public async Task SetValueShouldFailIfMismatchTypeForIntValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("Delay", false).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature Delay is an integer feature..."); }
public async Task SetValueShouldFailIfMismatchTypeForBooleanValue() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var exception = await featuresService.SetValue("Beta", 10).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe("The feature Beta is a boolean feature..."); }
public async Task SetValueShouldFailIfNoFeatureFound() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); string featureName = "X"; // Act var exception = await featuresService.SetValue(featureName, "test").ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe($"The feature {featureName} does not exist..."); }
public async Task SetValueShouldFailIfNotInsideTheAvailableStringChoices() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); string featureName = "Theme"; string newValue = "Blue"; // Act var exception = await featuresService.SetValue(featureName, newValue).ShouldThrowAsync <Exception>(); // Assert exception.Message.ShouldBe($"The value {newValue} is not a valid choice for feature {featureName}..."); }
public async Task SetValueShouldUpdateStringFeature() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); string newValue = "dark"; // Act var result = await featuresService.SetValue("Theme", newValue); // Assert result.Server.ShouldNotBeNull(); if (result.Server != null) { result.Server.BooleanValue.ShouldBeNull(); result.Server.IntValue.ShouldBeNull(); result.Server.DecimalValue.ShouldBeNull(); result.Server.StringValue.ShouldBe(newValue); } }
public async Task SetValueShouldUpdateBooleanFeature() { // Arrange InitializeFeaturesData(); var featuresService = new FeaturesService(_db, new Settings()); // Act var result = await featuresService.SetValue("Beta", false); // Assert result.Server.ShouldNotBeNull(); if (result.Server != null) { result.Server.BooleanValue.HasValue.ShouldBeTrue(); if (result.Server.BooleanValue.HasValue) { result.Server.BooleanValue.Value.ShouldBeFalse(); } result.Server.IntValue.ShouldBeNull(); result.Server.DecimalValue.ShouldBeNull(); result.Server.StringValue.ShouldBeNull(); } }