public void AccessorBuilding_should_require_DefaultTreatment() { // Arrange var httpClientDouble = new HttpClientDouble(); var client = new HttpFeatureToggleClient(httpClientDouble, "url"); try { var booleanAccessor = client .CreateFeature <bool>("BooleanFeature") .AddBehavior("Disabled", false) .AddBehavior("Enabled", true) .Build(); Assert.Fail("Expected exception not thrown"); } catch (Exception e) { Assert.IsInstanceOf(typeof(InvalidOperationException), e); Assert.AreEqual("Cannot build a feature without default treatment defined.", e.Message); } }
public void AccessorBuilding_should_not_accept_unexistent_ForceTreatment() { // Arrange var httpClientDouble = new HttpClientDouble(); var client = new HttpFeatureToggleClient(httpClientDouble, "url"); try { var booleanAccessor = client .CreateFeature <bool>("BooleanFeature") .AddBehavior("Disabled", false) .AddBehavior("Enabled", true) .SetDefaultTreatment("Disabled") .ForceTreatmentIfNotNull("ANOTHER") .Build(); Assert.Fail("Expected exception not thrown"); } catch (Exception e) { Assert.IsInstanceOf(typeof(InvalidOperationException), e); Assert.AreEqual("Forced treatment does not match a defined treatment.", e.Message); } }