public void TemplateFileInvalidTemplate()
 {
     MockBuild build = new MockBuild();
     TemplateFile tf = new TemplateFile();
     tf.BuildEngine = build;
     tf.Template = new TaskItem("non_existant_file");
     tf.Tokens = GetTaskItems();
     Assert.IsFalse(tf.Execute());
     Assert.AreEqual(1, build.ErrorCount);
 }
Example #2
0
        public void TemplateFileInvalidTemplate()
        {
            MockBuild    build = new MockBuild();
            TemplateFile tf    = new TemplateFile();

            tf.BuildEngine = build;
            tf.Template    = new TaskItem("non_existant_file");
            tf.Tokens      = GetTaskItems();
            Assert.IsFalse(tf.Execute());
            Assert.AreEqual(1, build.ErrorCount);
        }
 public void TemplateFileDefault()
 {
     MockBuild build = new MockBuild();
     TemplateFile tf = new TemplateFile();
     tf.BuildEngine = build;
     tf.Template = new TaskItem(_templateFilename);
     tf.Tokens = GetTaskItems();
     Assert.IsTrue(tf.Execute());
     Assert.IsNotNull(tf.OutputFile);
     Assert.IsTrue(File.Exists(tf.OutputFile.ItemSpec));
     _replacedFilename = tf.OutputFile.ItemSpec;
     Assert.AreEqual(Path.ChangeExtension(_templateFilename, ".out"), _replacedFilename);
     string replaced = File.ReadAllText(tf.OutputFile.ItemSpec);
     Assert.AreEqual(_templateReplaced, replaced);
 }
Example #4
0
        public void TemplateFileNoTokens()
        {
            MockBuild    build = new MockBuild();
            TemplateFile tf    = new TemplateFile();

            tf.BuildEngine = build;
            tf.Template    = new TaskItem(_templateFilename);
            Assert.IsTrue(tf.Execute());
            Assert.IsNotNull(tf.OutputFile);
            Assert.IsTrue(File.Exists(tf.OutputFile.ItemSpec));
            _replacedFilename = tf.OutputFile.ItemSpec;
            Assert.AreEqual(Path.ChangeExtension(_templateFilename, ".out"), _replacedFilename);
            string replaced = File.ReadAllText(tf.OutputFile.ItemSpec);

            Assert.AreEqual(_template, replaced);
        }
Example #5
0
        public void TemplateFileReplace()
        {
            MockBuild    build = new MockBuild();
            TemplateFile tf    = new TemplateFile();

            tf.BuildEngine    = build;
            tf.Template       = new TaskItem(_templateFilename);
            tf.OutputFilename = _templateFilename;
            tf.Tokens         = GetTaskItems();
            Assert.IsTrue(tf.Execute());
            Assert.IsNotNull(tf.OutputFile);
            Assert.IsTrue(File.Exists(tf.OutputFile.ItemSpec));
            _replacedFilename = tf.OutputFile.ItemSpec;
            Assert.AreEqual(_templateFilename, _replacedFilename);
            string replaced = File.ReadAllText(tf.OutputFile.ItemSpec);

            Assert.AreEqual(_templateReplaced, replaced);
        }
Example #6
0
        public void TemplateFileMissingToken()
        {
            MockBuild    build = new MockBuild();
            TemplateFile tf    = new TemplateFile();

            tf.BuildEngine = build;
            tf.Template    = new TaskItem(_templateFilename);
            tf.Tokens      = GetTaskItemsMissing();
            Assert.IsTrue(tf.Execute());
            Assert.IsNotNull(tf.OutputFile);
            Assert.IsTrue(File.Exists(tf.OutputFile.ItemSpec));
            _replacedFilename = tf.OutputFile.ItemSpec;
            Assert.AreEqual(Path.ChangeExtension(_templateFilename, ".out"), _replacedFilename);
            string replaced         = File.ReadAllText(tf.OutputFile.ItemSpec);
            string shouldBeReplaced = _template.Replace("${TemplateItem}", "**Item1**").Replace("${CASEInsenSiTiveTest}", "**Item3**");

            Assert.AreEqual(shouldBeReplaced, replaced);
        }
Example #7
0
        public void TemplateFileNewFilename()
        {
            MockBuild    build = new MockBuild();
            TemplateFile tf    = new TemplateFile();

            tf.BuildEngine = build;
            tf.Template    = new TaskItem(_templateFilename);
            string outputfile = Path.Combine(Path.GetDirectoryName(_templateFilename), "Replacement.file");

            tf.OutputFilename = outputfile;
            tf.Tokens         = GetTaskItems();
            Assert.IsTrue(tf.Execute());
            Assert.IsNotNull(tf.OutputFile);
            Assert.IsTrue(File.Exists(tf.OutputFile.ItemSpec));
            _replacedFilename = tf.OutputFile.ItemSpec;
            Assert.AreEqual(outputfile, _replacedFilename);
            string replaced = File.ReadAllText(tf.OutputFile.ItemSpec);

            Assert.AreEqual(_templateReplaced, replaced);
        }
		public void TemplateFileMissingToken()
		{
			MockBuild build = new MockBuild();
			TemplateFile tf = new TemplateFile();
			tf.BuildEngine = build;
			tf.Template = new TaskItem(_templateFilename);
			tf.Tokens = GetTaskItemsMissing();
			Assert.IsTrue(tf.Execute());
			Assert.IsNotNull(tf.OutputFile);
			Assert.IsTrue(File.Exists(tf.OutputFile.ItemSpec));
			_replacedFilename = tf.OutputFile.ItemSpec;
			Assert.AreEqual(Path.ChangeExtension(_templateFilename, ".out"), _replacedFilename);
			string replaced = File.ReadAllText(tf.OutputFile.ItemSpec);
			string shouldBeReplaced = _template.Replace("${TemplateItem}", "**Item1**").Replace("${CASEInsenSiTiveTest}", "**Item3**");
			Assert.AreEqual(shouldBeReplaced, replaced);
		}
		public void TemplateFileNewFilename()
		{
			MockBuild build = new MockBuild();
			TemplateFile tf = new TemplateFile();
			tf.BuildEngine = build;
			tf.Template = new TaskItem(_templateFilename);
			string outputfile = Path.Combine(Path.GetDirectoryName(_templateFilename), "Replacement.file");
			tf.OutputFilename = outputfile;
			tf.Tokens = GetTaskItems();
			Assert.IsTrue(tf.Execute());
			Assert.IsNotNull(tf.OutputFile);
			Assert.IsTrue(File.Exists(tf.OutputFile.ItemSpec));
			_replacedFilename = tf.OutputFile.ItemSpec;
			Assert.AreEqual(outputfile, _replacedFilename);
			string replaced = File.ReadAllText(tf.OutputFile.ItemSpec);
			Assert.AreEqual(_templateReplaced, replaced);
		}