public void TestProfilingSession_StepImpl_HandleException()
        {
            var name = "test";
            var expectedException = new Exception();
            var exceptionHandled  = false;

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

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

            mockProfiler.Setup(profiler => profiler.Step(name, null)).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.StepImpl(name, null));
        }
        public void TestProfilingSession_StepImpl()
        {
            var name = "test";

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

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

            mockProfiler.Setup(profiler => profiler.Step(name, null)).Returns(mockStep.Object);
            var target = new ProfilingSession(mockProfiler.Object);


            Assert.AreEqual(mockStep.Object, target.StepImpl(name, null));
        }
Esempio n. 3
0
        public void TestProfilingSession_StepImpl_HandleException()
        {
            var name = "test";
            var expectedException = new Exception();
            var exceptionHandled = false;

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

            // mock profiler
            var mockProfiler = new Mock<IProfiler>();
            mockProfiler.Setup(profiler => profiler.Step(name, null, null)).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.StepImpl(name, null));
        }
Esempio n. 4
0
        public void TestProfilingSession_StepImpl()
        {
            var name = "test";

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

            // mock profiler
            var mockProfiler = new Mock<IProfiler>();
            mockProfiler.Setup(profiler => profiler.Step(name, null, It.IsAny<string>())).Returns(mockStep.Object);
            var target = new ProfilingSession(mockProfiler.Object);

            Assert.AreEqual(mockStep.Object, target.StepImpl(name, null));
        }