Esempio n. 1
0
        public void LogActivity_Complete_writes_current_method_name()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            var observer = new Mock<IObserver<LogEntry>>();
            observer
                .Setup(
                    o => o.OnNext(
                        It.Is<LogEntry>(
                            e => e.CallingMethod == methodName &&
                                 e.EventType == TraceEventType.Stop)));

            var helper = new AsyncTestHelper();

            using (var activity = Log.Enter(() => { }))
            using (TestHelper.LogToConsole())
            using (observer.Object.SubscribeToLogEvents())
            {
                var result = helper.BeginSomething(
                    _ => activity.Complete(() => { }),
                    activity);
                helper.EndSomething(result);
            }

            observer.VerifyAll();
        }
Esempio n. 2
0
        public void LogActivity_Complete_writes_current_method_name()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            var observer   = new Mock <IObserver <LogEntry> >();

            observer
            .Setup(
                o => o.OnNext(
                    It.Is <LogEntry>(
                        e => e.CallingMethod == methodName &&
                        e.EventType == TraceEventType.Stop)));

            var helper = new AsyncTestHelper();

            using (var activity = Log.Enter(() => { }))
                using (TestHelper.LogToConsole())
                    using (observer.Object.SubscribeToLogEvents())
                    {
                        var result = helper.BeginSomething(
                            _ => activity.Complete(() => { }),
                            activity);
                        helper.EndSomething(result);
                    }

            observer.VerifyAll();
        }
Esempio n. 3
0
        public void LogActivity_Trace_captures_current_method_name()
        {
            var observer = new Mock <IObserver <LogEntry> >();

            observer.Setup(o => o.OnNext(
                               It.Is <LogEntry>(
                                   e => e.CallingMethod.Contains("BeginSomething"))));
            observer.Setup(o => o.OnNext(
                               It.Is <LogEntry>(
                                   e => e.CallingMethod.Contains("EndSomething"))));

            var helper = new AsyncTestHelper();

            using (var activity = Log.Enter(() => { }))
                using (TestHelper.LogToConsole())
                    using (observer.Object.SubscribeToLogEvents())
                    {
                        var result = helper.BeginSomething(
                            _ => activity.Complete(() => { }),
                            activity);
                        helper.EndSomething(result);
                    }

            observer.VerifyAll();
        }
Esempio n. 4
0
        public void LogActivity_Trace_captures_current_method_name()
        {
            var observer = new Mock<IObserver<LogEntry>>();
            observer.Setup(o => o.OnNext(
                It.Is<LogEntry>(
                    e => e.CallingMethod.Contains("BeginSomething"))));
            observer.Setup(o => o.OnNext(
                It.Is<LogEntry>(
                    e => e.CallingMethod.Contains("EndSomething"))));

            var helper = new AsyncTestHelper();

            using (var activity = Log.Enter(() => { }))
            using (TestHelper.LogToConsole())
            using (observer.Object.SubscribeToLogEvents())
            {
                var result = helper.BeginSomething(
                    _ => activity.Complete(() => { }),
                    activity);
                helper.EndSomething(result);
            }

            observer.VerifyAll();
        }