public void MiddlewareSuccess_CorrectEventContent()
        {
            var source     = new DiagnosticListener("Autofac");
            var subscriber = new MockSubscriber();

            subscriber.Enable(DiagnosticEventKeys.MiddlewareSuccess);
            source.Subscribe(subscriber, subscriber.IsEnabled);

            var context = MockResolveRequestContext();

            source.MiddlewareSuccess(context, Mock.Of <IResolveMiddleware>());
            var e = Assert.Single(subscriber.Events);

            Assert.Equal(DiagnosticEventKeys.MiddlewareSuccess, e.Key);
            Assert.IsType <MiddlewareDiagnosticData>(e.Value);
        }
        public void OperationFailure_CorrectEventContent()
        {
            var source     = new DiagnosticListener("Autofac");
            var subscriber = new MockSubscriber();

            subscriber.Enable(DiagnosticEventKeys.OperationFailure);
            source.Subscribe(subscriber, subscriber.IsEnabled);

            var operation = MockResolveOperation();

            source.OperationFailure(operation, new DivideByZeroException());
            var e = Assert.Single(subscriber.Events);

            Assert.Equal(DiagnosticEventKeys.OperationFailure, e.Key);
            Assert.IsType <OperationFailureDiagnosticData>(e.Value);
        }
        public void OperationSuccess_CorrectEventContent()
        {
            var source     = new DiagnosticListener("Autofac");
            var subscriber = new MockSubscriber();

            subscriber.Enable(DiagnosticEventKeys.OperationSuccess);
            source.Subscribe(subscriber, subscriber.IsEnabled);

            var operation = MockResolveOperation();

            source.OperationSuccess(operation, "instance");
            var e = Assert.Single(subscriber.Events);

            Assert.Equal(DiagnosticEventKeys.OperationSuccess, e.Key);
            Assert.IsType <OperationSuccessDiagnosticData>(e.Value);
        }
        public void OperationStart_CorrectEventContent()
        {
            var source     = new DiagnosticListener("Autofac");
            var subscriber = new MockSubscriber();

            subscriber.Enable(DiagnosticEventKeys.OperationStart);
            source.Subscribe(subscriber, subscriber.IsEnabled);

            var operation = MockResolveOperation();
            var request   = MockResolveRequest();

            source.OperationStart(operation, request);
            var e = Assert.Single(subscriber.Events);

            Assert.Equal(DiagnosticEventKeys.OperationStart, e.Key);
            Assert.IsType <OperationStartDiagnosticData>(e.Value);
        }