コード例 #1
0
ファイル: ReportTest.cs プロジェクト: pvandervelde/Sherlock
        public void Create()
        {
            var productName = "product";
            var productVersion = "1.2.3.4";
            var owner = "owner";
            var description = "description";
            var start = DateTimeOffset.Now;
            var end = start.AddSeconds(10);

            var header = new ReportHeader(
                start,
                end,
                productName,
                productVersion,
                owner,
                description);

            var name = "name";
            var section = new TestSection(
                "someName",
                DateTimeOffset.Now,
                DateTimeOffset.Now,
                true,
                new List<DateBasedTestInformation>(),
                new List<DateBasedTestInformation>(),
                new List<DateBasedTestInformation>());
            var testSections = new List<TestSection>
                {
                    section
                };
            var reportSection = new ReportSection(name, testSections);
            var sections = new List<ReportSection>
                {
                    reportSection
                };

            var report = new Report(header, sections);

            Assert.AreSame(header, report.Header);
            Assert.That(
                report.Sections(),
                Is.EquivalentTo(sections));
        }
コード例 #2
0
        public void Create()
        {
            var name = "name";
            var section = new TestSection(
               "someName",
               DateTimeOffset.Now,
               DateTimeOffset.Now,
               true,
               new List<DateBasedTestInformation>(),
               new List<DateBasedTestInformation>(),
               new List<DateBasedTestInformation>());
            var sections = new List<TestSection> { section };

            var reportSection = new ReportSection(name, sections);

            Assert.AreEqual(name, reportSection.Name);
            Assert.That(
                reportSection.Sections(),
                Is.EquivalentTo(sections));
        }
コード例 #3
0
        public void RoundTripSerialise()
        {
            var name = "name";
            var section = new TestSection(
               "someName",
               DateTimeOffset.Now,
               DateTimeOffset.Now,
               true,
               new List<DateBasedTestInformation>(),
               new List<DateBasedTestInformation>(),
               new List<DateBasedTestInformation>());
            var sections = new List<TestSection> { section };

            var reportSection = new ReportSection(name, sections);
            var otherReportSection = AssertExtensions.RoundTripSerialize(reportSection);

            Assert.AreEqual(reportSection.Name, otherReportSection.Name);

            // We'll assume that if one of the fields is correct then the other fields will be correct
            // too. This is (relatively) safe because there is a serialize / deserialize test for
            // the TestSection class.
            Assert.AreEqual(reportSection.Sections().Count(), otherReportSection.Sections().Count());
            Assert.AreEqual(reportSection.Sections().First().Name, otherReportSection.Sections().First().Name);
        }
コード例 #4
0
ファイル: ReportTest.cs プロジェクト: pvandervelde/Sherlock
        public void RoundTripSerialise()
        {
            var productName = "product";
            var productVersion = "1.2.3.4";
            var owner = "owner";
            var description = "description";
            var start = DateTimeOffset.Now;
            var end = start.AddSeconds(10);

            var header = new ReportHeader(
                start,
                end,
                productName,
                productVersion,
                owner,
                description);

            var name = "name";
            var section = new TestSection(
                "someName",
                DateTimeOffset.Now,
                DateTimeOffset.Now,
                true,
                new List<DateBasedTestInformation>(),
                new List<DateBasedTestInformation>(),
                new List<DateBasedTestInformation>());
            var testSections = new List<TestSection>
                {
                    section
                };
            var reportSection = new ReportSection(name, testSections);
            var sections = new List<ReportSection>
                {
                    reportSection
                };

            var report = new Report(header, sections);
            var otherReport = AssertExtensions.RoundTripSerialize(report);

            // We'll assume that if one of the fields is correct then the other fields will be correct
            // too. This is (relatively) safe because there is a serialize / deserialize test for
            // the ReportHeader class.
            Assert.AreEqual(report.Header.ProductName, otherReport.Header.ProductName);

            // We'll assume that if one of the fields is correct then the other fields will be correct
            // too. This is (relatively) safe because there is a serialize / deserialize test for
            // the TestSection class.
            Assert.AreEqual(report.Sections().Count(), otherReport.Sections().Count());
            Assert.AreEqual(report.Sections().First().Name, otherReport.Sections().First().Name);
        }
コード例 #5
0
        private static IReport BuildReport(
            string productName,
            string productVersion,
            string owner,
            string description,
            DateTimeOffset start,
            DateTimeOffset end,
            string sectionName,
            TestSection section)
        {
            var header = new ReportHeader(
                start,
                end,
                productName,
                productVersion,
                owner,
                description);

            var testSections = new List<TestSection>
                {
                    section
                };
            var reportSection = new ReportSection(sectionName, testSections);
            var sections = new List<ReportSection>
                {
                    reportSection
                };

            return new Report(header, sections);
        }
コード例 #6
0
        /// <summary>
        /// Creates the XML that describes a test section.
        /// </summary>
        /// <param name="section">The report section that holds the test section information.</param>
        /// <returns>
        /// A string containing the desired XML.
        /// </returns>
        private static string CreateTestSectionXml(ReportSection section)
        {
            var testSectionTemplate = EmbeddedResourceExtracter.LoadEmbeddedTextFile(
                Assembly.GetExecutingAssembly(),
                @"Sherlock.Shared.Core.Reporting.Templates.TestSectionTemplate.xml");
            string testSections = string.Empty;

            foreach (var testSection in section.Sections())
            {
                var messages = CreateTestSectionMessagesXml(testSection);
                var builder = new StringBuilder(testSectionTemplate);
                {
                    builder.Replace(@"${TEST_SECTION_NAME}$", EscapeTextForUseInXml(testSection.Name));
                    builder.Replace(
                        @"${TEST_SECTION_START_TIME}$",
                        EscapeTextForUseInXml(testSection.StartTime.ToString("o", CultureInfo.CurrentCulture)));
                    builder.Replace(
                        @"${TEST_SECTION_END_TIME}$",
                        EscapeTextForUseInXml(testSection.EndTime.ToString("o", CultureInfo.CurrentCulture)));
                    builder.Replace(
                        @"${TEST_SECTION_WAS_SUCCESSFUL}$",
                        EscapeTextForUseInXml(testSection.WasSuccessful.ToString()));

                    builder.Replace(@"${TEST_SECTION_MESSAGES}$", messages);
                }

                testSections += builder.ToString();
            }

            return testSections;
        }