示例#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();
        }
示例#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();
        }
示例#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();
        }
示例#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();
        }