Exemple #1
0
        public void TestNotFoundMonitor()
        {
            var app     = DebuggerHelper.GetApplication();
            var console = app.Make <HttpDebuggerConsole>();
            var monitor = app.Make <IMonitor>();

            App.Instance("DebuggerProvider.IndexMonitor", new List <string>
            {
                "titlenotfound",
                "title"
            });

            var handler = new OnceRecordMonitorHandler("title", "ms", new[] { "tags" }, () => "helloworld");

            monitor.Monitor(handler);

            string ret;
            var    statu = HttpHelper.Get("http://localhost:9478/debug/monitor/get-monitors-index", out ret);

            console.Stop();
            Assert.AreEqual(HttpStatusCode.OK, statu);
            Assert.AreEqual(
                "{\"Response\":[{\"name\":\"title\",\"value\":\"helloworld\",\"unit\":\"ms\",\"tags\":[\"tags\"]}]}",
                ret);
        }
Exemple #2
0
        public void TestRepeatRegisterMonitor()
        {
            var app     = DebuggerHelper.GetApplication();
            var console = app.Make <HttpDebuggerConsole>();
            var monitor = app.Make <IMonitor>();

            var handler = new OnceRecordMonitorHandler("title", "ms", new[] { "tags" }, () => "helloworld");

            monitor.Monitor(handler);
            console.Stop();
            ExceptionAssert.Throws <RuntimeException>(() =>
            {
                monitor.Monitor(handler);
            });
        }
Exemple #3
0
        public void TestForEachMonitor()
        {
            var app     = DebuggerHelper.GetApplication();
            var console = app.Make <HttpDebuggerConsole>();
            var monitor = app.Make <MonitorStore>();

            console.Stop();
            var handler = new OnceRecordMonitorHandler("title", "ms", new[] { "tags" }, () => "helloworld");

            monitor.Monitor(handler);

            foreach (var result in monitor)
            {
                Assert.AreEqual(handler, result);
                break;
            }
        }