Beispiel #1
0
        public void TestDiagnosticsController()
        {
            var client     = Startup.Client;
            var acceptText = "application/text,text/plain";

            //Heartbeat
            DiagnosticsController.Reset();
            var serverStatus = client.ExecuteGetString(acceptText, "api/diagnostics/heartbeat");

            Assert.AreEqual("StatusOK", serverStatus, "Expected StatusOK in heartbeat");
            // throw error
            DiagnosticsController.Reset();
            var exc = TestUtil.ExpectFailWith <Exception>(() => client.ExecuteGetString(acceptText, "api/diagnostics/throwerror"));

            Assert.IsTrue(exc.Message.Contains("TestException"), "Expected TestException thrown");
            //get/set time offset
            // current should be zero
            var currOffset = client.ExecuteGetString(acceptText, "api/diagnostics/timeoffset");

            Assert.IsTrue(currOffset.StartsWith("Current offset: 0 minutes"), "Expected no offset");
            // set 60 minutes forward
            currOffset = client.ExecuteGetString(acceptText, "api/diagnostics/timeoffset/60");
            Assert.IsTrue(currOffset.StartsWith("Current offset: 60 minutes"), "Expected 60 minutes offset");
            // set back to 0
            currOffset = client.ExecuteGetString(acceptText, "api/diagnostics/timeoffset/0");
            Assert.IsTrue(currOffset.StartsWith("Current offset: 0 minutes"), "Expected no offset");

            //test that heartbeat call is not logged in web log - controller method sets log level to None
            var serverSession = Startup.BooksApp.OpenSession();
            var hbeatEntry    = serverSession.EntitySet <IWebCallLog>().Where(wl => wl.Url.Contains("heartbeat")).FirstOrDefault();

            Assert.IsNull(hbeatEntry, "Expected no heartbeat entry in web log.");
        }