public void ConfigurationIsLoadedCorrectly()
        {
            var reader = new NetReflectorConfigurationReader();
            var xml = new XmlDocument();
            xml.LoadXml(@"
<cruisecontrol>
    <project name=""WebTrunkTest"">
        <tasks>
            <xslt>
                <xmlfile>File 1</xmlfile>
                <xslfile>File 2</xslfile>
                <outputfile>File 3</outputfile>
                <xsltArgs>
                    <namedValue name=""ArgumentName"" value=""SomeValue"" />
                </xsltArgs>
            </xslt>
        </tasks>
    </project>
</cruisecontrol>
");
            var configuration = reader.Read(xml, null);
            Assert.IsNotNull(configuration, "Configuration not loaded");
            var project = configuration.Projects["WebTrunkTest"] as Project;
            Assert.IsNotNull(project, "Project not loaded");
            Assert.AreNotEqual(0, project.Tasks.Length, "Tasks not loaded");
            var task = project.Tasks[0] as XslTransformationTask;
            Assert.IsNotNull(task, "Task not correctly loaded");
            Assert.AreEqual("File 1", task.XMLFile, "XMLFile is incorrect");
            Assert.AreEqual("File 2", task.XSLFile, "XSLFile is incorrect");
            Assert.AreEqual("File 3", task.OutputFile, "OutputFile is incorrect");
            Assert.AreEqual(1, task.XsltArgs.Length, "Invalid number of xslt arguments");
            Assert.AreEqual("ArgumentName", task.XsltArgs[0].Name, "Argument name is incorrect");
            Assert.AreEqual("SomeValue", task.XsltArgs[0].Value, "Argument value is incorrect");
        }
		public void ShouldBeAbleToLoadXmlWithDTD()
		{
			tempfile = TempFileUtil.CreateTempFile("config", "project1.xml", @"<project name=""p1"" />");
			string xml = 
@"<!DOCTYPE cruisecontrol [ 
	<!ENTITY project1 SYSTEM ""file:" + tempfile + @""">
]> 
<cruisecontrol>&project1;</cruisecontrol>";
			XmlTextReader xr = new XmlTextReader(new StringReader(xml));
			XmlValidatingLoader loader = new XmlValidatingLoader(xr);
			XmlDocument doc = loader.Load();
			Assert.IsNotNull(doc, "Unable to load document because it is not valid according to reader");
			IConfiguration config = new NetReflectorConfigurationReader().Read(doc, null);
			Assert.IsNotNull(config.Projects["p1"]);
		}
		public void ExampleConfigFilesShouldNotContainAnyInvalidElements()
		{
			NetReflectorConfigurationReader reader = new NetReflectorConfigurationReader();

			string[] configFiles = new string[]
				{
					"ccnet.config", "CVSAndNAntAndEmailPublisherCCNet.config", "VSSAndDevenvAndNUnitCCNet.config", "P4AndDevenv.config"
				};
			foreach (string f in configFiles)
			{
				filename = f;
				XmlDocument xml = LoadConfigXml();
				Assert.IsNotNull(reader.Read(xml, null));
			}
		}
		public void InvalidTaskXmlShouldThrowNetReflectorException()
		{
			NetReflectorConfigurationReader reader = new NetReflectorConfigurationReader();
			XmlDocument xml = new XmlDocument();
			xml.LoadXml(@"
<cruisecontrol>
       <project name=""WebTrunkTest"" artifactDirectory=""..\WebTrunkTest"" >

               <tasks>
                       <build type=""nant"">
							<executable>d:\build\bin\nant.exe</executable>
                       </build>
               </tasks>
       </project>
</cruisecontrol>
");
		    Assert.That(delegate { reader.Read(xml, null); },
                        Throws.TypeOf<ConfigurationException>());
		}
Ejemplo n.º 5
0
        public void ConfigurationIsLoadedCorrectly()
        {
            var reader = new NetReflectorConfigurationReader();
            var xml = new XmlDocument();
            xml.LoadXml(@"
<cruisecontrol>
    <project name=""WebTrunkTest"">
        <tasks>
            <merge target=""somewhere"">
                <files>
                    <file>File 1</file>
                    <file action=""Copy"">File 2</file>
                    <file action=""Merge"">File 3</file>
                </files>
            </merge>
        </tasks>
    </project>
</cruisecontrol>
");
            var configuration = reader.Read(xml, null);
            Assert.IsNotNull(configuration, "Configuration not loaded");
            var project = configuration.Projects["WebTrunkTest"] as Project;
            Assert.IsNotNull(project, "Project not loaded");
            Assert.AreNotEqual(0, project.Tasks.Length, "Tasks not loaded");
            var task = project.Tasks[0] as MergeFilesTask;
            Assert.IsNotNull(task, "Task not correctly loaded");
            Assert.AreEqual("somewhere", task.TargetFolder, "TargetFolder is incorrect");

            var expected = new MergeFileInfo[] {
                new MergeFileInfo{FileName = "File 1", MergeAction = MergeFileInfo.MergeActionType.Merge},
                new MergeFileInfo{FileName = "File 2", MergeAction = MergeFileInfo.MergeActionType.Copy},
                new MergeFileInfo{FileName = "File 3", MergeAction = MergeFileInfo.MergeActionType.Merge}
            };
            Assert.AreEqual(task.MergeFiles.Length, expected.Length, "File count incorrect");
            for (var loop = 0; loop < expected.Length; loop++)
            {
                Assert.AreEqual(expected[loop].FileName, task.MergeFiles[loop].FileName, string.Format(System.Globalization.CultureInfo.CurrentCulture,"FileName on {0} does not match", loop));
                Assert.AreEqual(expected[loop].MergeAction, task.MergeFiles[loop].MergeAction, string.Format(System.Globalization.CultureInfo.CurrentCulture,"MergeAction on {0} does not match", loop));
            }
        }
Ejemplo n.º 6
0
        public void AttributeOnElementThrowsException()
        {
            var reader = new NetReflectorConfigurationReader();
            var xml = new XmlDocument();
            xml.LoadXml(@"
<cruisecontrol>
    <project name=""WebTrunkTest"">
        <tasks>
            <merge target=""somewhere"">
                <files me=""wrong"">
                    <file>File 1</file>
                    <file action=""Copy"">File 2</file>
                    <file action=""Merge"">File 3</file>
                </files>
            </merge>
        </tasks>
    </project>
</cruisecontrol>
");
            Assert.That(delegate { reader.Read(xml, null); },
                        Throws.TypeOf<ConfigurationException>());
        }
 public DefaultConfigurationFileLoader(NetReflectorConfigurationReader reader)
 {
     this.reader = reader;
     reader.InvalidNodeEventHandler += new InvalidNodeEventHandler(WarnOnInvalidNode);
     handler = new ValidationEventHandler(HandleSchemaEvent);
 }
 public DefaultConfigurationFileLoader(NetReflectorConfigurationReader reader)
 {
     this.reader = reader;
     reader.InvalidNodeEventHandler += new InvalidNodeEventHandler(WarnOnInvalidNode);
     handler = new ValidationEventHandler(HandleSchemaEvent);
 }
		protected void CreateReader()
		{
			reader = new NetReflectorConfigurationReader();
		}