コード例 #1
0
        public void ShouldFailWhenInputInvalid()
        {
            string input   = @"<This is some invalid xml";
            string xslfile = TempFileUtil.CreateTempXmlFile(TestFolder, "samplestylesheet.xsl", TestData.StyleSheetContents);

            Assert.That(delegate { new XslTransformer().Transform(input, xslfile, null); },
                        Throws.TypeOf <CruiseControlException>());
        }
コード例 #2
0
        public void LoadConfiguration_BadXml()
        {
            FileInfo configFile = new FileInfo(TempFileUtil.CreateTempXmlFile(TempFileUtil.CreateTempDir(this), "loadernet.config"
                                                                              , "<test><a><b/></test>"));

            Assert.That(delegate { fileLoader.LoadConfiguration(configFile); },
                        Throws.TypeOf <ConfigurationException>());
        }
コード例 #3
0
 public void ShouldFailOnFailedProcessResult()
 {
     TempFileUtil.CreateTempXmlFile(string.Format(logfile, task.LogFileId), "<output/>");
     ExpectToExecuteAndReturn(FailedProcessResult());
     task.Run(result);
     Assert.AreEqual(2, result.TaskResults.Count);
     Assert.AreEqual("<output/>" + ProcessResultOutput, result.TaskOutput);
     Assert.IsTrue(result.Failed);
 }
コード例 #4
0
 public void ShouldAutomaticallyMergeTheBuildOutputFile()
 {
     TempFileUtil.CreateTempXmlFile(string.Format(logfile, task.LogFileId), "<output/>");
     ExpectToExecuteAndReturn(SuccessfulProcessResult());
     task.Run(result);
     Assert.AreEqual(2, result.TaskResults.Count);
     Assert.That(result.TaskOutput, Is.EqualTo("<output/>"));
     Assert.IsTrue(result.Succeeded);
 }
コード例 #5
0
        public void LoadConfigurationFile()
        {
            string      xml        = "<cruisecontrol />";
            FileInfo    configFile = new FileInfo(TempFileUtil.CreateTempXmlFile(TempFileUtil.CreateTempDir(this), "loadernet.config", xml));
            XmlDocument config     = fileLoader.LoadConfiguration(configFile);

            Assert.IsNotNull(config);
            Assert.AreEqual(xml, config.OuterXml);
        }
コード例 #6
0
 public void ShouldFailOnFailedProcessResult()
 {
     AddDefaultAssemblyToCheck(task);
     TempFileUtil.CreateTempXmlFile(logfile, "<output/>");
     ExpectToExecuteAndReturn(FailedProcessResult());
     task.Run(result);
     Assert.AreEqual(1, result.TaskResults.Count);
     Assert.That(result.TaskOutput, Is.EqualTo(ProcessResultOutput));
     Assert.IsTrue(result.Failed);
 }
コード例 #7
0
 public void ShouldAutomaticallyMergeTheBuildOutputFile()
 {
     AddDefaultAssemblyToCheck(task);
     TempFileUtil.CreateTempXmlFile(logfile, "<output/>");
     ExpectToExecuteAndReturn(SuccessfulProcessResult());
     task.Run(result);
     Assert.AreEqual(1, result.TaskResults.Count);
     Assert.That(result.TaskOutput, Is.Empty);
     Assert.IsTrue(result.Succeeded);
 }
コード例 #8
0
        public void ShouldTransformData()
        {
            string input   = TestData.LogFileContents;
            string xslfile = TempFileUtil.CreateTempXmlFile(TestFolder, "samplestylesheet.xsl", TestData.StyleSheetContents);

            string output = new XslTransformer().Transform(input, xslfile, null);

            Assert.IsNotNull(output);
            Assert.IsTrue(!String.Empty.Equals(output), "Transform returned no data");
        }
コード例 #9
0
        public void TestCreateTempXmlDoc()
        {
            TempFileUtil.CreateTempDir(TempDir);
            string path = TempFileUtil.CreateTempXmlFile(TempDir, "foobar.xml", "<test />");

            Assert.IsTrue(File.Exists(path));
            XmlDocument doc = new XmlDocument();

            doc.Load(path);
        }
コード例 #10
0
        public void ShouldPassThroughXSLTArgs()
        {
            string input   = TestData.LogFileContents;
            string xslfile = TempFileUtil.CreateTempXmlFile(TestFolder, "samplestylesheet.xsl", TestData.StyleSheetContentsWithParam);

            Hashtable xsltArgs = new Hashtable();

            xsltArgs["myParam"] = "myValue";
            string output = new XslTransformer().Transform(input, xslfile, xsltArgs);

            Assert.IsTrue(output.IndexOf("myValue") > 0);
        }
コード例 #11
0
        public void HandleFileChanged()
        {
            tempFile = TempFileUtil.CreateTempXmlFile("FileChangedWatcherTest", "foo.xml", "<derek><zoolander/></derek>");
            using (FileChangedWatcher watcher = new FileChangedWatcher(tempFile))
            {
                watcher.OnFileChanged += new FileSystemEventHandler(FileChanged);

                UpdateFile("<rob><schneider/></rob>");
                Assert.AreEqual(1, filechangedCount);

                UpdateFile("<joseph><conrad/></joseph");
                Assert.AreEqual(2, filechangedCount);
            }
        }
コード例 #12
0
        public void HandleFileMove()
        {
            tempFile = TempFileUtil.GetTempFilePath("FileChangedWatcherTest", "foo.xml");
            using (FileChangedWatcher watcher = new FileChangedWatcher(tempFile))
            {
                watcher.OnFileChanged += new FileSystemEventHandler(FileChanged);

                string file = TempFileUtil.CreateTempXmlFile("FileChangedWatcherTest", "bar.xml", "<adam><sandler /></adam>");
                new FileInfo(file).MoveTo(tempFile);

                Assert.IsTrue(monitor.WaitOne(5000, false));
                monitor.Reset();
                Assert.AreEqual(1, filechangedCount);
            }
        }
コード例 #13
0
        private string CreateTemporaryConfigurationFile()
        {
            string configXml = @"<configuration>
	<system.runtime.remoting>
		<application>
			<channels>
				<channel ref=""tcp"" port=""35354"" name=""ccnet"">
					<serverProviders>
						<formatter ref=""binary"" typeFilterLevel=""Full"" />
					</serverProviders>
				</channel>
				<channel ref=""http"" port=""35355"" name=""ccnet2"">
					<serverProviders>
						<formatter ref=""binary"" typeFilterLevel=""Full"" />
					</serverProviders>
				</channel>
			</channels>
		</application>
	</system.runtime.remoting>
</configuration>";

            TempFileUtil.CreateTempDir("RemoteCruiseServerTest");
            return(TempFileUtil.CreateTempXmlFile("RemoteCruiseServerTest", "remote.config", configXml));
        }
コード例 #14
0
 private void UpdateFile(string text)
 {
     TempFileUtil.CreateTempXmlFile("FileChangedWatcherTest", "foo.xml", text);
     Assert.IsTrue(monitor.WaitOne(10000, false));
     monitor.Reset();
 }
コード例 #15
0
//		public static string CreateConfigFile()
//		{
//			return CreateConfigFile(ConfigurationMother.Content());
//		}

        public static string CreateConfigFile(string content)
        {
            TempFileUtil.CreateTempDir(TEMP_DIR, false);
            return(TempFileUtil.CreateTempXmlFile(TEMP_DIR, "testConfig.xml", content));
        }
コード例 #16
0
 public static string CreateBuildFile(string content)
 {
     TempFileUtil.CreateTempDir(TEMP_DIR);
     return(TempFileUtil.CreateTempXmlFile(TEMP_DIR, NANT_TEST_BUILDFILE, content));
 }