public void GetFeatureMemoizesTheFeature() { var adapter = MockRepository.GenerateStub <IAdapter>(); var flipper = new Flipper(adapter); var feature = flipper.Feature("Test"); Assert.That(flipper.Feature("Test"), Is.SameAs(feature)); }
public void EnableEnablesTheFeature() { var flipper = new Flipper(new MemoryAdapter()); flipper.Enable("Test"); Assert.That(flipper.Feature("Test").BooleanValue, Is.True); }
public void ShouldEnableAPercentageOfTimeGate() { var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.PercentageOfTimeGate, 10); Assert.That(Adapter.Get(feature)[PercentageOfTimeGate.KEY], Is.EqualTo("10")); }
public void ShouldRemoveFeature() { Adapter.Add(Flipper.Feature("Stats")); Adapter.Add(Flipper.Feature("Search")); Adapter.Remove(Flipper.Feature("Stats")); Assert.That(Adapter.Features, Is.EquivalentTo(new[] { "Search" })); }
public void DisableDisablesTheFeature() { var flipper = new Flipper(new MemoryAdapter()); flipper.Enable("Test"); flipper.Disable("Test"); Assert.That(flipper.Feature("Test").BooleanValue, Is.False); }
public void ShouldEnableABooleanGate() { var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.BooleanGate, true); Assert.That(Adapter.Get(feature)[BooleanGate.KEY], Is.EqualTo("true")); }
public void GetFeatureSetsInstrumenterOnFeature() { var instrumenter = MockRepository.GenerateStub <IInstrumenter>(); var flipper = new Flipper(MockRepository.GenerateStub <IAdapter>(), instrumenter); var feature = flipper.Feature("Test"); Assert.That(feature.Instrumenter, Is.EqualTo(instrumenter)); }
public void GetFeatureSetsAdapterOnFeature() { var adapter = MockRepository.GenerateStub <IAdapter>(); var flipper = new Flipper(adapter); var feature = flipper.Feature("Test"); Assert.That(feature.Adapter, Is.EqualTo(flipper.Adapter)); }
public void SetUp() { var clientConfig = new ConsulClientConfiguration {Address = new Uri("http://127.0.0.1:9500")}; var client = new ConsulClient(clientConfig); var adapter = new ConsulAdapter(client); var flipper = new Flipper(adapter); _feature = flipper.Feature("unobtanium"); }
public void ShouldDisableABooleanGate() { var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.BooleanGate, true); Adapter.Disable(feature, feature.BooleanGate, false); Assert.That(Adapter.Get(feature)[BooleanGate.KEY], Is.Null); }
public void ShouldDisableAPercentageOfActorsGate() { var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.PercentageOfActorsGate, 15); Adapter.Disable(feature, feature.PercentageOfActorsGate, 0); Assert.That(Adapter.Get(feature)[PercentageOfActorsGate.KEY], Is.EqualTo("0")); }
public void SetUp() { var clientConfig = new ConsulClientConfiguration(); clientConfig.Address = "127.0.0.1:9500"; var client = new Client(clientConfig); var adapter = new ConsulAdapter(client); var flipper = new Flipper(adapter); _feature = flipper.Feature("unobtanium"); }
public void ShouldEnableActorsForActorGate() { var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.ActorGate, "22"); Adapter.Enable(feature, feature.ActorGate, "asdf"); Assert.That(Adapter.Get(feature)[ActorGate.KEY], Is.EquivalentTo(new[] { "22", "asdf" })); }
public void ShouldFailWhenUnsupportedGateTypeIsDisabled() { var feature = Flipper.Feature("Stats"); var gate = MockRepository.GenerateStub <IGate>(); gate.Stub(x => x.DataType).Return(typeof(string)); gate.Stub(x => x.Name).Return("TEST"); Adapter.Disable(feature, gate, "foo"); }
public void ShouldDisableActorForActorGateWhenItIsTheLastActor() { var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.ActorGate, "asdf"); Adapter.Disable(feature, feature.ActorGate, "asdf"); Assert.That(Adapter.Get(feature)[ActorGate.KEY], Is.Empty); }
public void ShouldDisableActorForActorGateWhenThereAreMultipleActors() { var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.ActorGate, "22"); Adapter.Enable(feature, feature.ActorGate, "asdf"); Adapter.Disable(feature, feature.ActorGate, "22"); Assert.That(Adapter.Get(feature)[ActorGate.KEY], Is.EquivalentTo(new[] { "asdf" })); }
public void ShouldFailWhenUnsupportedGateTypeIsRetrieved() { var feature = Flipper.Feature("Stats"); var gate = MockRepository.GenerateStub <IGate>(); gate.Stub(x => x.DataType).Return(typeof(string)); gate.Stub(x => x.Name).Return("TEST"); feature.Gates.Add(gate); Adapter.Get(feature); }
public void ShouldRecordInstrumentationWhenLoadingFeatures() { var feature = Flipper.Feature("Stats"); var result = Adapter.Features; var expectedPayload = new InstrumentationPayload { Operation = "features", AdapterName = "memory", Result = result, }; Assert.That(Instrumenter.Events.First().Type, Is.EqualTo(InstrumentationType.AdapterOperation)); Assert.That(Instrumenter.Events.First().Payload, Is.EqualTo(expectedPayload)); }
public void ShouldRecordInstrumentationWhenAddingFeature() { var feature = Flipper.Feature("Stats"); Adapter.Add(feature); var expectedPayload = new InstrumentationPayload { Operation = "add", AdapterName = "memory", FeatureName = "Stats", }; Assert.That(Instrumenter.Events.First().Type, Is.EqualTo(InstrumentationType.AdapterOperation)); Assert.That(Instrumenter.Events.First().Payload, Is.EqualTo(expectedPayload)); }
public void ShouldFullyDisableTheFeatureWhenBooleanGateIsDisabled() { var actor22 = new object(); var group = new object(); var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.BooleanGate, true); Adapter.Enable(feature, feature.GroupGate, group); Adapter.Enable(feature, feature.ActorGate, actor22); Adapter.Enable(feature, feature.PercentageOfActorsGate, 25); Adapter.Enable(feature, feature.PercentageOfTimeGate, 45); Adapter.Disable(feature, feature.BooleanGate, false); Assert.That(Adapter.Get(feature), Is.EqualTo(EmptyResult())); }
public void ShouldRemoveAllGateValuesWhenFeatureCleared() { var actor22 = new object(); var group = new object(); var feature = Flipper.Feature("Stats"); Adapter.Enable(feature, feature.BooleanGate, true); Adapter.Enable(feature, feature.GroupGate, group); Adapter.Enable(feature, feature.ActorGate, actor22); Adapter.Enable(feature, feature.PercentageOfActorsGate, 25); Adapter.Enable(feature, feature.PercentageOfTimeGate, 45); Adapter.Clear(feature); Assert.That(Adapter.Get(feature), Is.EqualTo(EmptyResult())); }
public void ShouldRecordInstrumentationWhenDisablingFeature() { var feature = Flipper.Feature("Stats"); var gate = feature.PercentageOfActorsGate; var value = 22; Adapter.Disable(feature, gate, value); var expectedPayload = new InstrumentationPayload { Operation = "disable", AdapterName = "memory", FeatureName = "Stats", GateName = "percentage_of_actors", }; Assert.That(Instrumenter.Events.First().Type, Is.EqualTo(InstrumentationType.AdapterOperation)); Assert.That(Instrumenter.Events.First().Payload, Is.EqualTo(expectedPayload)); }
public void GetFeatureSetsInstrumenterOnFeature() { var instrumenter = MockRepository.GenerateStub<IInstrumenter>(); var flipper = new Flipper(MockRepository.GenerateStub<IAdapter>(), instrumenter); var feature = flipper.Feature("Test"); Assert.That(feature.Instrumenter, Is.EqualTo(instrumenter)); }
public void ShouldSetDefaultGateValues() { var feature = Flipper.Feature("Stats"); Assert.That(Adapter.Get(feature), Is.EquivalentTo(EmptyResult())); }
public void GetFeatureMemoizesTheFeature() { var adapter = MockRepository.GenerateStub<IAdapter>(); var flipper = new Flipper(adapter); var feature = flipper.Feature("Test"); Assert.That(flipper.Feature("Test"), Is.SameAs(feature)); }
public void GetFeatureSetsAdapterOnFeature() { var adapter = MockRepository.GenerateStub<IAdapter>(); var flipper = new Flipper(adapter); var feature = flipper.Feature("Test"); Assert.That(feature.Adapter, Is.EqualTo(flipper.Adapter)); }
public void ShouldAddMultipleFeatures() { Adapter.Add(Flipper.Feature("Stats")); Adapter.Add(Flipper.Feature("Search")); Assert.That(Adapter.Features, Is.EquivalentTo(new[] { "Stats", "Search" })); }
public void ShouldAddFeature() { Adapter.Add(Flipper.Feature("Stats")); Assert.That(Adapter.Features, Is.EquivalentTo(new[] { "Stats" })); }
public void ShouldReadABooleanGate() { const string stats = "Stats"; rubyAdapter.Enable(stats); Assert.That(flipper.Feature(stats).IsEnabled()); }