Пример #1
0
        public void report_can_have_no_channels()
        {
            var report = PrtgReport.Successful(new List <PrtgResult>());

            report.Serialize()
            .Should().HaveElement("text")
            .Which.Should().HaveValue("No channels");
        }
Пример #2
0
        public void can_create_failed_report()
        {
            var report = PrtgReport.Failed("Your error message");

            report.Serialize().Should().BeEquivalentTo(new XElement("prtg",
                                                                    new XElement("error", "1"),
                                                                    new XElement("text", "Your error message")
                                                                    ));
        }
Пример #3
0
        public void report_can_have_additional_message()
        {
            var report = PrtgReport.Successful("it works", new[]
            {
                new PrtgResult("some channel", 10)
            });

            report.Serialize()
            .Should().HaveElement("text")
            .Which.Should().HaveValue("it works");
        }
Пример #4
0
        public void report_must_have_unique_channels()
        {
            var report = PrtgReport.Successful(new[]
            {
                new PrtgResult("First channel", 10),
                new PrtgResult("First channel", 1.5f),
                new PrtgResult("Second channel", 1),
                new PrtgResult("Second channel", 12)
            });

            report.Serialize().Should().BeEquivalentTo(new XElement("prtg",
                                                                    new XElement("error", "1"),
                                                                    new XElement("text", "Duplicate channels: First channel, Second channel")
                                                                    ));
        }
Пример #5
0
        public void can_create_report_with_multiple_channels()
        {
            var report = PrtgReport.Successful(new[]
            {
                new PrtgResult("First channel", 10),
                new PrtgResult("Second channel", 1.5f)
            });

            report.Serialize().Should().BeEquivalentTo(new XElement("prtg",
                                                                    new XElement("result",
                                                                                 new XElement("channel", "First channel"),
                                                                                 new XElement("value", "10")
                                                                                 ),
                                                                    new XElement("result",
                                                                                 new XElement("channel", "Second channel"),
                                                                                 new XElement("value", "1.5")
                                                                                 )
                                                                    ));
        }
Пример #6
0
        public void can_print_prtg_report_to_the_console()
        {
            using (var consoleOutput = CapturedConsoleOutput.StartCapturing())
            {
                PrtgExeScriptAdvanced.Run(() => PrtgReport.Successful(new[]
                {
                    new PrtgResult("First channel", 10),
                    new PrtgResult("Second channel", 20)
                }));

                consoleOutput.ReadAll().Should().Be(
                    "<prtg>" +
                    "<result>" +
                    "<channel>First channel</channel>" +
                    "<value>10</value>" +
                    "</result>" +
                    "<result>" +
                    "<channel>Second channel</channel>" +
                    "<value>20</value>" +
                    "</result>" +
                    "</prtg>"
                    );
            }
        }