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 sherlockVersion = typeof(ReportHeader).Assembly.GetName().Version;

            Assert.AreEqual(start, header.StartTime);
            Assert.AreEqual(end, header.EndTime);

            Assert.AreEqual(Environment.MachineName, header.HostName);
            Assert.AreEqual(owner, header.UserName);
            Assert.AreEqual(sherlockVersion, header.SherlockVersion);

            Assert.AreEqual(productName, header.ProductName);
            Assert.AreEqual(productVersion, header.ProductVersion);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Report"/> class.
        /// </summary>
        /// <param name="header">The header for the report.</param>
        /// <param name="sections">The sections that contain the test results.</param>
        /// <exception cref="ArgumentNullException">
        ///   Thrown when <paramref name="header"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///   Thrown when <paramref name="sections"/> is <see langword="null" />.
        /// </exception>
        public Report(ReportHeader header, IEnumerable<ReportSection> sections)
        {
            {
             Lokad.Enforce.Argument(() => header);
             Lokad.Enforce.Argument(() => sections);
             }

             Header = header;
             m_Sections.AddRange(sections);
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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);
        }
        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);
        }
        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 otherHeader = AssertExtensions.RoundTripSerialize(header);

            Assert.AreEqual(header.StartTime, otherHeader.StartTime);
            Assert.AreEqual(header.EndTime, otherHeader.EndTime);

            Assert.AreEqual(header.HostName, otherHeader.HostName);
            Assert.AreEqual(header.UserName, otherHeader.UserName);
            Assert.AreEqual(header.SherlockVersion, otherHeader.SherlockVersion);

            Assert.AreEqual(header.ProductName, otherHeader.ProductName);
            Assert.AreEqual(header.ProductVersion, otherHeader.ProductVersion);
        }
        /// <summary>
        /// Builds the report.
        /// </summary>
        /// <returns>A new instance of the current report.</returns>
        public IReport Build()
        {
            if (m_StartTime.Equals(DateTimeOffset.MinValue))
            {
                throw new CannotBuildAnUninitializedReportException();
            }

            if (!HasReportBeenFinalized)
            {
                throw new CannotBuildNonFinalizedReportException();
            }

            var header = new ReportHeader(
                m_StartTime,
                m_EndTime,
                m_ProductName,
                m_ProductVersion,
                m_TestOwner,
                m_TestDescription);

            var sections = from map in m_Sections
                select new ReportSection(map.Key, map.Value);

            return new Report(header, sections);
        }