Exemplo n.º 1
0
        public void CheckGenerateReportWithMultipleSectionsAndEntries()
        {
            const string k_ExpectedOutput = @"==== Section One ====
Entry Header: Entry Body
Entry Header 2: Entry Body 2
Entry Header 3: Entry Body 3

==== Section Two ====
Entry Header 4: Entry Body 4
Entry Header 5: Entry Body 5
Entry Header 6: Entry Body 6

==== Last 20 Events ====
";

            var sectionOneHandle = DiagnosticReport.GetSection(k_SectionOneTitle);

            DiagnosticReport.AddSectionEntry(sectionOneHandle, "Entry Header", "Entry Body");
            DiagnosticReport.AddSectionEntry(sectionOneHandle, "Entry Header 2", "Entry Body 2");
            DiagnosticReport.AddSectionEntry(sectionOneHandle, "Entry Header 3", "Entry Body 3");

            var sectionTwoHandle = DiagnosticReport.GetSection(k_SectionTwoTitle);

            DiagnosticReport.AddSectionEntry(sectionTwoHandle, "Entry Header 4", "Entry Body 4");
            DiagnosticReport.AddSectionEntry(sectionTwoHandle, "Entry Header 5", "Entry Body 5");
            DiagnosticReport.AddSectionEntry(sectionTwoHandle, "Entry Header 6", "Entry Body 6");

            var report = DiagnosticReport.GenerateReport();

            Assert.AreEqual(k_ExpectedOutput, report);
        }
Exemplo n.º 2
0
        public void CheckGeneratedEventsOverTwentyAreReported()
        {
            const string k_ExpectedOutput = @"==== Last 20 Events ====
Event 11: Event Body 11
Event 12: Event Body 12
Event 13: Event Body 13
Event 14: Event Body 14
Event 15: Event Body 15
Event 16: Event Body 16
Event 17: Event Body 17
Event 18: Event Body 18
Event 19: Event Body 19
Event 20: Event Body 20
Event 21: Event Body 21
Event 22: Event Body 22
Event 23: Event Body 23
Event 24: Event Body 24
Event 25: Event Body 25
Event 26: Event Body 26
Event 27: Event Body 27
Event 28: Event Body 28
Event 29: Event Body 29
Event 30: Event Body 30
";

            for (int i = 0; i <= 30; i++)
            {
                DiagnosticReport.AddEventEntry($"Event {i}", $"Event Body {i}");
            }


            var report = DiagnosticReport.GenerateReport();

            Assert.AreEqual(k_ExpectedOutput, report);
        }
Exemplo n.º 3
0
        public void CheckFullReport()
        {
            const string k_ExpectedOutput = @"==== Section One ====
Section One Entry One: Simple

==== Section Two ====
Section Two Entry One: Simple

Section Two Entry Two: (2)
    FOO=BAR
    BAZ=100

==== Last 20 Events ====
Event 11: Event Body 11
Event 12: Event Body 12
Event 13: Event Body 13
Event 14: Event Body 14
Event 15: Event Body 15
Event 16: Event Body 16
Event 17: Event Body 17
Event 18: Event Body 18
Event 19: Event Body 19
Event 20: Event Body 20
Event 21: Event Body 21
Event 22: Event Body 22
Event 23: Event Body 23
Event 24: Event Body 24
Event 25: Event Body 25
Event 26: Event Body 26
Event 27: Event Body 27
Event 28: Event Body 28
Event 29: Event Body 29
Event 30: Event Body 30
";

            var sectionOneHandle = DiagnosticReport.GetSection(k_SectionOneTitle);

            DiagnosticReport.AddSectionEntry(sectionOneHandle, "Section One Entry One", "Simple");

            for (int i = 0; i <= 30; i++)
            {
                DiagnosticReport.AddEventEntry($"Event {i}", $"Event Body {i}");
            }

            var sectionTwoHandle = DiagnosticReport.GetSection(k_SectionTwoTitle);

            DiagnosticReport.AddSectionEntry(sectionTwoHandle, "Section Two Entry One", "Simple");
            DiagnosticReport.AddSectionBreak(sectionTwoHandle);
            DiagnosticReport.AddSectionEntry(sectionTwoHandle, "Section Two Entry Two", @"(2)
    FOO=BAR
    BAZ=100
");

            var report = DiagnosticReport.GenerateReport();

            Debug.Log(report);
            Assert.AreEqual(k_ExpectedOutput, report);
        }
Exemplo n.º 4
0
        public void CheckSimpleReportGenerationIsCorrect()
        {
            const string k_ExpectedOutput = "==== Section One ====\n\n==== Last 20 Events ====\n";

            var sectionOneHandle = DiagnosticReport.GetSection(k_SectionOneTitle);
            var report           = DiagnosticReport.GenerateReport();

            Assert.IsFalse(String.IsNullOrEmpty(report));
            Assert.AreEqual(k_ExpectedOutput, report);
        }
Exemplo n.º 5
0
        public void CheckGeneratedEventsAreReported()
        {
            const string k_ExpectedOutput = @"==== Last 20 Events ====
Event One: Event Body One
";

            DiagnosticReport.AddEventEntry("Event One", "Event Body One");

            var report = DiagnosticReport.GenerateReport();

            Assert.AreEqual(k_ExpectedOutput, report);
        }
Exemplo n.º 6
0
        public void SectionReportsStayInCreatedOrder()
        {
            var sectionOneHandle = DiagnosticReport.GetSection(k_SectionOneTitle);
            var sectionTwoHandle = DiagnosticReport.GetSection(k_SectionTwoTitle);
            var reportOne        = DiagnosticReport.GenerateReport();

            DiagnosticReport.StartReport();
            sectionTwoHandle = DiagnosticReport.GetSection(k_SectionTwoTitle);
            sectionOneHandle = DiagnosticReport.GetSection(k_SectionOneTitle);
            var reportTwo = DiagnosticReport.GenerateReport();

            Assert.AreNotEqual(reportOne, reportTwo);
        }
 /// <summary>
 /// Return true if the diagnostic report contains the given text
 /// </summary>
 /// <param name="match">String to search for</param>
 /// <returns>True if the report contains the given text</returns>
 protected bool DoesDiagnosticReportContain(string match) =>
 DiagnosticReport.GenerateReport().Contains(match);
 /// <summary>
 /// Return true if the diagnostic report contains text that matches the given regex
 /// </summary>
 /// <param name="match">Regex to match</param>
 /// <returns>True if the report matches the regex</returns>
 protected bool DoesDiagnosticReportContain(Regex match) =>
 match.IsMatch(DiagnosticReport.GenerateReport());