public void FixtureInit() { ilMergeAvailable = File.Exists( Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft\ILMerge\ILMerge.exe")); MockBuild buildEngine = new MockBuild(); testDirectory = TaskUtility.makeTestDirectory(buildEngine); ILMerge task = new ILMerge(); task.BuildEngine = buildEngine; if (TaskUtility.CalledInBuildDirectory) { assemblyA = Path.Combine(testDirectory, @"A.dll"); assemblyB = Path.Combine(testDirectory, @"B.dll"); excludeFile = Path.Combine(testDirectory, @"ExcludeTypes.txt"); keyFile = Path.Combine(testDirectory, @"keypair.snk"); } else { string config = TaskUtility.BuildConfiguration; string assDir = Path.GetFullPath(TaskUtility.AssemblyDirectory); assemblyA = Path.GetFullPath(Path.Combine(assDir, @"..\..\ILMerge\A\bin\" + config + @"\A.dll")); assemblyB = Path.GetFullPath(Path.Combine(assDir, @"..\..\ILMerge\B\bin\" + config + @"\B.dll")); excludeFile = Path.Combine(assDir, @"ILMerge\ExcludeTypes.txt"); keyFile = Path.Combine(assDir, @"ILMerge\keypair.snk"); } inputAssemblies = TaskUtility.StringArrayToItemArray(assemblyA, assemblyB); }
public void FixtureInit() { MockBuild buildEngine = new MockBuild(); TaskUtility.makeTestDirectory(buildEngine); _templateFilename = Path.Combine(TaskUtility.TestDirectory, typeof(TemplateFileTest).Name + ".txt"); }
public void FixtureInit() { MockBuild buildEngine = new MockBuild(); this.testDirectory = TaskUtility.makeTestDirectory(buildEngine); if (TaskUtility.CalledInBuildDirectory) { this.assemblyA = Path.Combine(this.testDirectory, @"A.dll"); this.assemblyB = Path.Combine(this.testDirectory, @"B.dll"); this.excludeFile = Path.Combine(this.testDirectory, @"ExcludeTypes.txt"); this.keyFile = Path.Combine(this.testDirectory, @"keypair.snk"); } else { string config = TaskUtility.BuildConfiguration; string assDir = Path.GetFullPath(TaskUtility.AssemblyDirectory); this.assemblyA = Path.GetFullPath(Path.Combine(assDir, @"..\..\ILMerge\A\bin\" + config + @"\A.dll")); this.assemblyB = Path.GetFullPath(Path.Combine(assDir, @"..\..\ILMerge\B\bin\" + config + @"\B.dll")); this.excludeFile = Path.Combine(assDir, @"ILMerge\ExcludeTypes.txt"); this.keyFile = Path.Combine(assDir, @"ILMerge\keypair.snk"); } this.inputAssemblies = TaskUtility.StringArrayToItemArray(this.assemblyA, this.assemblyB); }
public void Setup() { MockBuild buildEngine = new MockBuild(); testDirectory = TaskUtility.makeTestDirectory(buildEngine); task = new WebDownload(); task.BuildEngine = new MockBuild(); }
public void NUnitExecute() { #region Find NUnit installation string nunitPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); nunitPath = Path.Combine(nunitPath, NUnit.DEFAULT_NUNIT_DIRECTORY); RegistryKey buildKey = Registry.ClassesRoot.OpenSubKey(@"NUnitTestProject\shell\open\command"); if (buildKey == null) { Assert.Ignore(@"Can't find NUnit installation"); } nunitPath = buildKey.GetValue(null, nunitPath).ToString(); Regex nunitRegex = new Regex("(.+)nunit-gui\\.exe", RegexOptions.IgnoreCase); Match pathMatch = nunitRegex.Match(nunitPath); nunitPath = pathMatch.Groups[1].Value.Replace("\"", ""); #endregion Find NUnit installation MockBuild buildEngine = new MockBuild(); string testDirectory = TaskUtility.makeTestDirectory(buildEngine); NUnit task = new NUnit(); task.BuildEngine = buildEngine; task.Assemblies = TaskUtility.StringArrayToItemArray( Path.Combine(nunitPath, "nunit.framework.tests.dll")); task.WorkingDirectory = testDirectory; task.OutputXmlFile = Path.Combine(testDirectory, @"nunit.framework.tests-results.xml"); Assert.IsTrue(task.Execute(), "Execute Failed"); }
public void NUnitExecute() { #region Find NUnit installation string nunitPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); nunitPath = Path.Combine(nunitPath, NUnit.DEFAULT_NUNIT_DIRECTORY); RegistryKey buildKey = Registry.ClassesRoot.OpenSubKey(@"NUnitTestProject\shell\open\command"); if (buildKey == null) Assert.Ignore(@"Can't find NUnit installation"); nunitPath = buildKey.GetValue(null, nunitPath).ToString(); Regex nunitRegex = new Regex("(.+)nunit-gui\\.exe", RegexOptions.IgnoreCase); Match pathMatch = nunitRegex.Match(nunitPath); nunitPath = pathMatch.Groups[1].Value.Replace("\"", ""); #endregion Find NUnit installation MockBuild buildEngine = new MockBuild(); string testDirectory = TaskUtility.makeTestDirectory(buildEngine); NUnit task = new NUnit(); task.BuildEngine = buildEngine; task.Assemblies = TaskUtility.StringArrayToItemArray( Path.Combine(nunitPath, "nunit.framework.tests.dll")); task.WorkingDirectory = testDirectory; task.OutputXmlFile = Path.Combine(testDirectory, @"nunit.framework.tests-results.xml"); Assert.IsTrue(task.Execute(), "Execute Failed"); }
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 LogOnNoSourceFilesTest() { var task = new Merge(); var mockBuild = new MockBuild(); task.BuildEngine = mockBuild; var result = task.Execute(); Assert.IsTrue(result); Assert.That(mockBuild.MessageLog, Is.EqualTo(Resources.MergeCompleteNoSourceFiles + Environment.NewLine)); }
public void Setup() { MockBuild buildEngine = new MockBuild(); testDirectory = Path.Combine(TaskUtility.makeTestDirectory( buildEngine ), "ChecksumTest"); Directory.CreateDirectory( testDirectory ); // Create test file inputFiles = new string[2]; inputFiles[0] = Path.Combine( testDirectory, "testFile1.txt" ); inputFiles[1] = Path.Combine( testDirectory, "testFile2.txt" ); File.WriteAllText( inputFiles[0], "foo\nbar" ); File.WriteAllText( inputFiles[1], "test2\ntest2" ); }
public void Setup() { MockBuild buildEngine = new MockBuild(); testDirectory = Path.Combine(TaskUtility.makeTestDirectory(buildEngine), "ChecksumTest"); Directory.CreateDirectory(testDirectory); // Create test file inputFiles = new string[2]; inputFiles[0] = Path.Combine(testDirectory, "testFile1.txt"); inputFiles[1] = Path.Combine(testDirectory, "testFile2.txt"); File.WriteAllText(inputFiles[0], "foo\nbar"); File.WriteAllText(inputFiles[1], "test2\ntest2"); }
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); }
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); }
public void Copy() { MockBuild buildEngine = new MockBuild(); string testDirectory = TaskUtility.makeTestDirectory(buildEngine); RoboCopy copy = new RoboCopy(); copy.BuildEngine = buildEngine; copy.SourceFolder = @"..\..\..\"; copy.DestinationFolder = Path.Combine(testDirectory, "RoboCopy"); copy.Mirror = true; copy.ExcludeFolders = new string[] { ".svn", "bin", "obj", "Test" }; copy.ExcludeFiles = new string[] { "*.resx", "*.csproj", "*.webinfo", "*.log" }; bool result = copy.Execute(); Assert.IsTrue(result); }
public void FixtureInit() { MockBuild buildEngine = new MockBuild(); testDirectory = TaskUtility.makeTestDirectory(buildEngine); // Create test files files = new string[3]; files[0] = Path.Combine(testDirectory, @"numberupdate.txt"); files[1] = Path.Combine(testDirectory, @"versionupdate.txt"); files[2] = Path.Combine(testDirectory, @"parsetestupdate.txt"); File.WriteAllText(files[0], "1.0.0.0"); File.WriteAllText(files[1], "1.0.0.0"); File.WriteAllText(files[2], "Today's date is: @DATE@." + Environment.NewLine + "In case you didn't understand, today's date is: @DATE@!"); }
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); }
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 NUnitExecuteWhenToolPathIsDefined(int majorVersion, int minorVersion, int number) { string nUnitDirName = string.Format("NUnit {0}.{1}.{2}", majorVersion, minorVersion, number); string nunitPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), nUnitDirName), "bin"); if (!Directory.Exists(nunitPath)) { Assert.Inconclusive("{0} - not found", nunitPath); } MockBuild buildEngine = new MockBuild(); string testDirectory = TaskUtility.makeTestDirectory(buildEngine); NUnit task = new NUnit(); task.ToolPath = nunitPath; task.BuildEngine = buildEngine; task.Assemblies = TaskUtility.StringArrayToItemArray(Path.Combine(nunitPath, "nunit.framework.tests.dll")); task.WorkingDirectory = testDirectory; Assert.IsTrue(task.Execute(), "Execute Failed"); }
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 FixtureInit() { MockBuild buildEngine = new MockBuild(); TaskUtility.makeTestDirectory(buildEngine); }
public void SetUp() { _mockBuild = new MockBuild(); TaskUtility.makeTestDirectory(_mockBuild); }
public void FixtureInit() { MockBuild buildEngine = new MockBuild(); TaskUtility.makeTestDirectory(buildEngine); _templateFilename = Path.Combine(TaskUtility.TestDirectory, typeof (TemplateFileTest).Name + ".txt"); }
public void FixtureInit() { this.isILMergeAvailable = File.Exists(Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft\ILMerge\ILMerge.exe")); MockBuild buildEngine = new MockBuild(); this.testDirectory = TaskUtility.makeTestDirectory(buildEngine); ILMerge task = new ILMerge(); task.BuildEngine = buildEngine; if (TaskUtility.CalledInBuildDirectory) { this.assemblyA = Path.Combine(this.testDirectory, @"A.dll"); this.assemblyB = Path.Combine(this.testDirectory, @"B.dll"); this.excludeFile = Path.Combine(this.testDirectory, @"ExcludeTypes.txt"); this.keyFile = Path.Combine(this.testDirectory, @"keypair.snk"); } else { string config = TaskUtility.BuildConfiguration; string assDir = Path.GetFullPath(TaskUtility.AssemblyDirectory); this.assemblyA = Path.GetFullPath(Path.Combine(assDir, @"..\..\ILMerge\A\bin\" + config + @"\A.dll")); this.assemblyB = Path.GetFullPath(Path.Combine(assDir, @"..\..\ILMerge\B\bin\" + config + @"\B.dll")); this.excludeFile = Path.Combine(assDir, @"ILMerge\ExcludeTypes.txt"); this.keyFile = Path.Combine(assDir, @"ILMerge\keypair.snk"); } this.inputAssemblies = TaskUtility.StringArrayToItemArray(this.assemblyA, this.assemblyB); }