public void Should_conform_to_xml_schema()
        {
            string tempFileName = Path.GetTempFileName();
            try
            {
                var report = new TestReportCollection();
                var testReport = new TestReport(@"C:\Test.xap");
                testReport.AddResult(TestCaseResultFactory.CreatePassed());
                testReport.AddResult(TestCaseResultFactory.CreateFailed());
                testReport.AddResult(TestCaseResultFactory.CreateIgnored());

                report.Add(testReport);
                var trxReport = new TRXReport(report);
                trxReport.WriteXmlReport(tempFileName);

                File.ReadAllText(tempFileName).Trace();

                string xmlSchemaPath = @"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Xml\Schemas\vstst.xsd";
                IList<string> validationErrors = new List<string>();
                XmlSchemaValidatorHelper.ValidateSchema(tempFileName, File.ReadAllText(xmlSchemaPath), out validationErrors);

                foreach (var validationError in validationErrors)
                {
                    validationError.Trace();
                }

                validationErrors.Count.ShouldEqual(0);
            }
            catch (Exception)
            {
                if(File.Exists(tempFileName))
                    File.Delete(tempFileName);
                throw;
            }
        }
        public void Should_conform_to_xml_schema()
        {
            string tempFileName = Path.GetTempFileName();
            try
            {
                var report = new TestReportCollection();
                var testReport = new TestReport(@"C:\Test.xap");
                testReport.AddResult(TestCaseResultFactory.CreatePassed());
                //testReport.AddResult(TestCaseResultFactory.CreateFailed());
                //testReport.AddResult(TestCaseResultFactory.CreateIgnored());

                report.Add(testReport);
                var trxReport = new TRXReport(report);
                trxReport.WriteXmlReport(tempFileName);

                //File.ReadAllText(tempFileName).Trace();

                var xmlSchema = Resources.vstst;
                IList<string> validationErrors;
                XmlSchemaValidatorHelper.ValidateSchema(tempFileName, xmlSchema, out validationErrors);

                tempFileName.Trace();

                foreach (var validationError in validationErrors)
                {
                    validationError.Trace();
                }

                if (validationErrors.Any())
                {
                    Assert.Fail("Validation Errors:{0}{1}".FormatWith(Environment.NewLine, string.Join(Environment.NewLine, validationErrors)));
                }
            }
            catch (Exception)
            {
                if(File.Exists(tempFileName))
                    File.Delete(tempFileName);
                throw;
            }
        }
        private static void WriteXmlReport(TestReportCollection testReports, string xmlReportOutputPath, ReportOutputFileType reportOutputFileType)
        {
            if (!string.IsNullOrEmpty(xmlReportOutputPath))
            {
                IXmlReport xmlReport;
                switch (reportOutputFileType)
                {
                    case ReportOutputFileType.MSGenericTest:
                        xmlReport = new Reporting.Providers.TFS.TFS2010.MSGenericTestXmlReport(testReports);
                        break;
                    case ReportOutputFileType.StatLight:
                        xmlReport = new Reporting.Providers.Xml.XmlReport(testReports);
                        break;
                    case ReportOutputFileType.NUnit:
                        xmlReport = new Reporting.Providers.NUnit.NUnitXmlReport(testReports);
                        break;
                    case ReportOutputFileType.TRX:
                        xmlReport = new TRXReport(testReports);
                        break;
                    default:
                        throw new StatLightException("Unknown ReportOutputFileType chosen Name=[{0}], Value=[{1}]".FormatWith(reportOutputFileType.ToString(), (int)reportOutputFileType));
                }

                xmlReport.WriteXmlReport(xmlReportOutputPath);

                "*********************************"
                    .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorInformation, true);

                "Wrote XML report to:{0}{1}"
                    .FormatWith(Environment.NewLine, new FileInfo(xmlReportOutputPath).FullName)
                    .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorWarning, true);

                "*********************************"
                    .WrapConsoleMessageWithColor(Settings.Default.ConsoleColorInformation, true);
            }
        }