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);
        }
        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));
        }
        /// <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;
        }