public void HandlePostRequestHandler_CriticalException_Tests()
        {
            // setup for tests
            HttpContextBase    context = new MockHttpContext();
            PerformanceMonitor pm      = new PerformanceMonitor();

            // Critical Exception Handling
            pm.HandleEndRequest(null);
        }
        public void HandleEndRequest_ResponseCounters_Tests()
        {
            long responseCounter;

            byte[] buffer = Encoding.ASCII.GetBytes("Test");

            // setup for tests
            HttpContextBase    context = new MockHttpContext();
            PerformanceMonitor pm      = new PerformanceMonitor();

            pm.HandleBeginRequest(context);

            // ResponseCounter tests
            responseCounter = PerformanceMonitor.ResponseCounter;

            // context.Response.Filter.Length tests
            Assert.IsTrue(context.Response.Filter.Length == 0);

            // mock up a write to the response
            context.Response.Filter.Write(buffer, 0, 4);
            // calling HandleEndRequest
            pm.HandleEndRequest(context);

            // ResponseCounter tests
            Assert.IsTrue(PerformanceMonitor.ResponseCounter == responseCounter + 1);

            // context.Response.Filter.Length tests
            Assert.IsTrue(context.Response.Filter.Length == 115);
            Assert.IsTrue(PerformanceMonitor.ResponseSizeTally == 4);
            Assert.IsTrue(PerformanceMonitor.ResponseSizeMinimum == 4);
            Assert.IsTrue(PerformanceMonitor.ResponseSizeMaximum == 4);


            // calling HandleEndRequest for the second time
            pm.HandleEndRequest(context);

            // context.Response.Filter.Length tests
            Assert.IsTrue(context.Response.Filter.Length == 231);
            Assert.IsTrue(PerformanceMonitor.ResponseSizeTally == 115 + 4);
            Assert.IsTrue(PerformanceMonitor.ResponseSizeMinimum == 4);
            Assert.IsTrue(PerformanceMonitor.ResponseSizeMaximum == 115);
        }
        public void HandleEndRequest_Stopwatch_Tests()
        {
            // setup for tests
            HttpContextBase    context = new MockHttpContext();
            PerformanceMonitor pm      = new PerformanceMonitor();

            pm.HandleBeginRequest(context);
            pm.HandleEndRequest(context);

            // Stopwatch tests
            Post_Stopwatch_Tests(context, "request_timer");
        }