Inheritance: IInstrumenter
        public void ShouldRecordInstrumentationForIsEnabled([Values(true,false)] Boolean enabled)
        {
            var instrumenter = new MockInstrumenter();
            var feature = new Feature("Name", new MemoryAdapter(), instrumenter);

            if (enabled)
            {
                feature.Enable();
            } else
            {
                feature.Disable();
            }
            instrumenter.Events.Clear();

            feature.IsEnabled();

            var expectedPayload = new InstrumentationPayload {
                FeatureName = "Name",
                Operation = "enabled?",
                Thing = null,
                Result = enabled
            };
            var expectedEvent = new MockInstrumenter.Event {
                Type = InstrumentationType.FeatureOperation,
                Payload = expectedPayload,
            };

            Assert.That(instrumenter.Events, Has.Member(expectedEvent));
        }
        public void ShouldRecordGateInstrumentationForIsEnabledFor([Values(true,false)] Boolean enabled)
        {
            var instrumenter = new MockInstrumenter();
            var feature = new Feature("Name", new MemoryAdapter(), instrumenter);

            var flipperActor = MockActor("User:5");
            if (enabled)
            {
                feature.EnableActor(flipperActor);
            } else
            {
                feature.DisableActor(flipperActor);
            }
            instrumenter.Events.Clear();

            feature.IsEnabledFor(flipperActor);

            var expectedPayload = new InstrumentationPayload {
                FeatureName = "Name",
                GateName = "actor",
                Operation = "open?",
                Thing = flipperActor,
                Result = enabled,
            };
            if (enabled)
            {
                expectedPayload.GateName = feature.ActorGate.Name;
            }
            var expectedEvent = new MockInstrumenter.Event {
                Type = InstrumentationType.GateOperation,
                Payload = expectedPayload,
            };

            Assert.That(instrumenter.Events, Has.Member(expectedEvent));
        }
        public void ShouldRecordInstrumentationForDisable()
        {
            var instrumenter = new MockInstrumenter();
            var feature = new Feature("Name", new MemoryAdapter(), instrumenter);

            feature.Disable();

            var expectedPayload = new InstrumentationPayload {
                FeatureName = "Name",
                Operation = "disable",
                Thing = false,
            };

            Assert.That(instrumenter.Events.First().Type, Is.EqualTo(InstrumentationType.FeatureOperation));
            Assert.That(instrumenter.Events.First().Payload, Is.EqualTo(expectedPayload));
        }
        public void ShouldRecordInstrumentationForEnable()
        {
            var instrumenter = new MockInstrumenter();
            var feature = new Feature("Name", new MemoryAdapter(), instrumenter);

            var flipperActor = MockActor("User:5");
            feature.EnableActor(flipperActor);

            var expectedPayload = new InstrumentationPayload {
                FeatureName = "Name",
                Operation = "enable",
                Thing = flipperActor,
            };

            Assert.That(instrumenter.Events.First().Type, Is.EqualTo(InstrumentationType.FeatureOperation));
            Assert.That(instrumenter.Events.First().Payload, Is.EqualTo(expectedPayload));
        }
 public new void SetUp()
 {
     var decoratedAdapter = new MemoryAdapter();
     Instrumenter = new MockInstrumenter();
     Adapter = new InstrumentedAdapterDecorator(decoratedAdapter, Instrumenter);
 }
 public InstrumentationToken(MockInstrumenter instrumenter, InstrumentationType type, InstrumentationPayload payload)
 {
     _instrumenter = instrumenter;
     _type         = type;
     _payload      = payload;
 }
 public InstrumentationToken(MockInstrumenter instrumenter, InstrumentationType type, InstrumentationPayload payload)
 {
     _instrumenter = instrumenter;
     _type = type;
     _payload = payload;
 }