Ejemplo n.º 1
0
        public void TestProfilingSession_IgnoreImpl()
        {
            // mock step
            var mockStep = new Mock <IDisposable>();

            // mock profiler
            var mockProfiler = new Mock <IProfiler>();

            mockProfiler.Setup(profiler => profiler.Ignore()).Returns(mockStep.Object);
            var target = new ProfilingSession(mockProfiler.Object);


            Assert.AreEqual(mockStep.Object, target.IgnoreImpl());
        }
Ejemplo n.º 2
0
        public void TestProfilingSession_IgnoreImpl_HandleException()
        {
            var expectedException = new Exception();
            var exceptionHandled  = false;

            // mock profiler
            var mockProfiler = new Mock <IProfiler>();

            mockProfiler.Setup(profiler => profiler.Ignore()).Throws(expectedException);
            var target = new ProfilingSession(mockProfiler.Object);

            ProfilingSession.HandleExceptionHandler = (a, b) =>
            {
                Assert.AreEqual(expectedException, a);
                Assert.AreEqual(target, b);

                exceptionHandled = true;
            };

            // execute
            Assert.IsNull(target.IgnoreImpl());
        }
Ejemplo n.º 3
0
        public void TestProfilingSession_IgnoreImpl_HandleException()
        {
            var expectedException = new Exception();
            var exceptionHandled = false;

            // mock step
            var mockStep = new Mock<IDisposable>();

            // mock profiler
            var mockProfiler = new Mock<IProfiler>();
            mockProfiler.Setup(profiler => profiler.Ignore()).Throws(expectedException);
            var target = new ProfilingSession(mockProfiler.Object);

            // mock provider
            var mockProflingProvider = new Mock<IProfilerProvider>();
            mockProflingProvider.Setup(provider => provider.HandleException(It.IsAny<Exception>(), It.IsAny<object>()))
                .Callback<Exception, object>((a, b) =>
                {
                    Assert.AreEqual(expectedException, a);
                    Assert.AreEqual(target, b);

                    exceptionHandled = true;
                });
            ProfilingSession.ProfilerProvider = mockProflingProvider.Object;

            // execute
            Assert.IsNull(target.IgnoreImpl());
        }
Ejemplo n.º 4
0
        public void TestProfilingSession_IgnoreImpl()
        {
            // mock step
            var mockStep = new Mock<IDisposable>();

            // mock profiler
            var mockProfiler = new Mock<IProfiler>();
            mockProfiler.Setup(profiler => profiler.Ignore()).Returns(mockStep.Object);
            var target = new ProfilingSession(mockProfiler.Object);

            Assert.AreEqual(mockStep.Object, target.IgnoreImpl());
        }