Esempio n. 1
0
        public void ShouldStart()
        {
            // arrange
            MockDiagnosticsModule module = new MockDiagnosticsModule();

            // act
            module.TestStart(m_ctx);

            // assert
            module.m_diagnostics.Verify(x => x.Start());
        }
Esempio n. 2
0
        public void ShouldNotStartIfNoDiagnosticsProvided()
        {
            // arrange
            MockDiagnosticsModule module = new MockDiagnosticsModule(true);

            // act
            module.TestStart(m_ctx);

            // assert
            module.m_diagnostics.Verify(x => x.Start(), Times.Never());
        }
Esempio n. 3
0
        public void ShouldNotStopIfContentTypeIsNotHtml()
        {
            // arrange
            MockDiagnosticsModule module = new MockDiagnosticsModule();
            m_ctx.Response.ContentType = "other";
            module.TestStart(m_ctx);

            // act
            module.TestStop(m_ctx);

            // assert
            module.m_diagnostics.Verify(x => x.Stop(), Times.Never());
        }
Esempio n. 4
0
        public void ShouldStop()
        {
            // arrange
            MockDiagnosticsModule module = new MockDiagnosticsModule();
            module.TestStart(m_ctx);

            // act
            try
            {
                module.TestStop(m_ctx);
            }
            catch (HttpException)
            {
                // Because we don't have a real HttpContext, setting the response filter
                // throws an exception, because it's not overriding a HttpWriter. Problem
                // is the HttpWriter can only be set internally to the HttpResponse assembly.

                // assert
                module.m_diagnostics.Verify(x => x.Stop());
                return;
            }

            Assert.Fail("Setting the Filter didn't throw an HttpException");
        }