Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public void EnableEnablesTheFeature()
        {
            var flipper = new Flipper(new MemoryAdapter());

            flipper.Enable("Test");
            Assert.That(flipper.Feature("Test").BooleanValue, Is.True);
        }
Ejemplo n.º 3
0
        public void ShouldEnableAPercentageOfTimeGate()
        {
            var feature = Flipper.Feature("Stats");

            Adapter.Enable(feature, feature.PercentageOfTimeGate, 10);
            Assert.That(Adapter.Get(feature)[PercentageOfTimeGate.KEY], Is.EqualTo("10"));
        }
Ejemplo n.º 4
0
 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" }));
 }
Ejemplo n.º 5
0
 public void DisableDisablesTheFeature()
 {
     var flipper = new Flipper(new MemoryAdapter());
     flipper.Enable("Test");
     flipper.Disable("Test");
     Assert.That(flipper.Feature("Test").BooleanValue, Is.False);
 }
Ejemplo n.º 6
0
        public void ShouldEnableABooleanGate()
        {
            var feature = Flipper.Feature("Stats");

            Adapter.Enable(feature, feature.BooleanGate, true);
            Assert.That(Adapter.Get(feature)[BooleanGate.KEY], Is.EqualTo("true"));
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
 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");
 }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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"));
        }
Ejemplo n.º 12
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");
 }
Ejemplo n.º 13
0
        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" }));
        }
Ejemplo n.º 14
0
        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");
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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" }));
        }
Ejemplo n.º 17
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");
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
0
        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));
        }
Ejemplo n.º 21
0
        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()));
        }
Ejemplo n.º 22
0
        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()));
        }
Ejemplo n.º 23
0
        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));
        }
Ejemplo n.º 24
0
 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));
 }
Ejemplo n.º 25
0
        public void ShouldSetDefaultGateValues()
        {
            var feature = Flipper.Feature("Stats");

            Assert.That(Adapter.Get(feature), Is.EquivalentTo(EmptyResult()));
        }
Ejemplo n.º 26
0
 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));
 }
Ejemplo n.º 27
0
 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));
 }
Ejemplo n.º 28
0
 public void ShouldAddMultipleFeatures()
 {
     Adapter.Add(Flipper.Feature("Stats"));
     Adapter.Add(Flipper.Feature("Search"));
     Assert.That(Adapter.Features, Is.EquivalentTo(new[] { "Stats", "Search" }));
 }
Ejemplo n.º 29
0
 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());
        }