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