Esempio n. 1
0
        public void StopActivityIfExist_HandlesNullValue()
        {
            (DiagnosticListener listener, MockObserver mockObserver) = MockObserver.CreateListener();

            listener.StopActivityIfExist(null);
            Assert.IsFalse(mockObserver.Events.Any(), "Should not produce any events");
        }
Esempio n. 2
0
        public void ReportException_PropagatedAsEventPayload()
        {
            (DiagnosticListener listener, MockObserver mockObserver) = MockObserver.CreateListener();
            Exception exception = new IndexOutOfRangeException();

            listener.ReportException(exception);

            mockObserver.AssertException(exception);
        }
Esempio n. 3
0
        public void CreateAndStartActivity_ReportsStartEvent()
        {
            (DiagnosticListener listener, MockObserver mockObserver) = MockObserver.CreateListener();

            string   activityName = nameof(CreateAndStartActivity_ReportsStartEvent);
            Activity?activity     = listener.CreateAndStartActivity(activityName);
            string   eventName    = mockObserver.Events.Single().Key;

            Assert.AreEqual(activityName + ".Start", eventName);
        }
Esempio n. 4
0
        public void StopActivityIfExist_ReportsStopEvent()
        {
            (DiagnosticListener listener, MockObserver mockObserver) = MockObserver.CreateListener();

            string   activityName = nameof(StopActivityIfExist_ReportsStopEvent);
            Activity activity     = new Activity(activityName).Start();

            listener.StopActivityIfExist(activity);
            string eventName = mockObserver.Events.Single().Key;

            Assert.AreEqual(activityName + ".Stop", eventName);
            Assert.AreNotEqual(TimeSpan.Zero, activity.Duration, "Activity should be stoped");
        }
Esempio n. 5
0
        public void Constructor_SendOneWay_ReportsException()
        {
            ArithmeticException            exception    = new ArithmeticException();
            IServiceRemotingRequestMessage messsageMock = CreateMessage();
            Mock <IServiceRemotingClient>  clientMock   = new Mock <IServiceRemotingClient>();

            clientMock.Setup(c => c.SendOneWay(messsageMock)).Throws(exception);
            (DiagnosticListener listener, MockObserver observer) = MockObserver.CreateListener();
            ServiceRemotingClientWrapper wrapper = new ServiceRemotingClientWrapper(clientMock.Object, listener);

            Assert.ThrowsException <ArithmeticException>(() => wrapper.SendOneWay(messsageMock));
            observer.AssertException(exception);
        }
Esempio n. 6
0
        public async Task Constructor_RequestResponseAsync_ReportsException()
        {
            ArithmeticException            exception    = new ArithmeticException();
            IServiceRemotingRequestMessage messsageMock = CreateMessage();
            Mock <IServiceRemotingClient>  clientMock   = new Mock <IServiceRemotingClient>();

            clientMock.Setup(c => c.RequestResponseAsync(messsageMock)).Throws(exception);
            (DiagnosticListener listener, MockObserver observer) = MockObserver.CreateListener();
            ServiceRemotingClientWrapper wrapper = new ServiceRemotingClientWrapper(clientMock.Object, listener);

            await Assert.ThrowsExceptionAsync <ArithmeticException>(() => wrapper.RequestResponseAsync(messsageMock));

            observer.AssertException(exception);
        }