Exemplo n.º 1
0
        public void BuildPrtgResponseObject_Healthy()
        {
            var healthReportEntry =
                new HealthReportEntry(HealthStatus.Healthy, null, TimeSpan.FromMilliseconds(10), null, null);
            var healthReportEntries = new Dictionary <string, HealthReportEntry> {
                { "test", healthReportEntry }
            };
            var healthReport = new HealthReport(healthReportEntries, TimeSpan.FromMilliseconds(15));

            var expected = new List <PrtgResponseChannelValueBase>
            {
                new PrtgResponseChannelValueTimeSpan {
                    Channel = "TotalDuration", Value = 15
                },
                new PrtgResponseChannelValueTimeSpan {
                    Channel = "test.Duration", Value = 10
                },
            };

            var actual = PrtgResponseWriter.BuildPrtgResponseObject(healthReport);

            actual.Error.Should().Be(0);
            actual.Text.Should().Be(PrtgResponse.DefaultText);
            actual.Result.Should().BeEquivalentTo(expected, config => config.RespectingRuntimeTypes());
        }
Exemplo n.º 2
0
        public void BuildPrtgResponseObject_Unhealthy_ErrorText()
        {
            var healthReportEntry =
                new HealthReportEntry(HealthStatus.Unhealthy, null, TimeSpan.Zero, null, null);
            var healthReportEntries = new Dictionary <string, HealthReportEntry> {
                { "test", healthReportEntry }
            };
            var healthReport = new HealthReport(healthReportEntries, TimeSpan.Zero);

            var actual = PrtgResponseWriter.BuildPrtgResponseObject(healthReport);

            actual.Error.Should().Be(1);
            actual.Text.Should().BeEquivalentTo("test:\nUnhealthy");
        }
Exemplo n.º 3
0
        public void BuildPrtgResponseObject_Unhealthy()
        {
            var healthReportEntry =
                new HealthReportEntry(HealthStatus.Unhealthy, "description", TimeSpan.Zero, new Exception("testException"), null);
            var healthReportEntries = new Dictionary <string, HealthReportEntry> {
                { "test", healthReportEntry }
            };
            var healthReport = new HealthReport(healthReportEntries, TimeSpan.Zero);

            var actual = PrtgResponseWriter.BuildPrtgResponseObject(healthReport);

            actual.Error.Should().Be(1);
            actual.Text.Should().BeEquivalentTo("test:\ndescription\nSystem.Exception: testException");
        }