示例#1
0
        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;
            }
        }
示例#2
0
 public static bool ValidateSchema(string pathToXmlFileToValidate, out IList <string> validationErrors)
 {
     return(XmlSchemaValidatorHelper.ValidateSchema(pathToXmlFileToValidate, Resources.NUnitXmlResults, out validationErrors));
 }