public void GetUsingTaskCondition_SetInXml() { Project p = new Project(); p.LoadXml(TestData.ContentUsingTaskName); Assertion.AssertEquals("true", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).Condition); }
public void RemoveImport_SimpleDirtyAfterRemove() { string importPath = String.Empty; string projectPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); projectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("project.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.Imports.AddNewImport(importPath, "true"); object o = p.EvaluatedItems; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); p.Save(projectPath); Assertion.AssertEquals(false, p.IsDirty); p.Imports.RemoveImport(import); Assertion.AssertNull(CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath)); Assertion.AssertEquals(true, p.IsDirty); } finally { CompatibilityTestHelpers.RemoveFile(importPath); CompatibilityTestHelpers.RemoveFile(projectPath); } }
public void ProjectPathSet_ScalarValue() { string importPath = String.Empty; string importPath2 = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); importPath2 = ObjectModelHelpers.CreateFileInTempProjectDirectory("import2.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.AddNewImport(importPath, "true"); p.SetProperty("path", importPath2); object o = p.EvaluatedProperties; BuildProperty path = CompatibilityTestHelpers.FindBuildProperty(p, "path"); Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); import.ProjectPath = "$(path)"; Assertion.AssertEquals("$(path)", import.ProjectPath); o = p.EvaluatedProperties; Assertion.AssertEquals(false, object.Equals(importPath2, import.EvaluatedProjectPath)); // V9 OM does not evaluate imports } finally { CompatibilityTestHelpers.RemoveFile(importPath); CompatibilityTestHelpers.RemoveFile(importPath2); } }
public void RemoveEvaluatedItemSuccess() { try { string includePath = Path.Combine(ObjectModelHelpers.TempProjectDir, "*.foo"); List <string> files = CompatibilityTestHelpers.CreateFiles(4, "foo", "foo", ObjectModelHelpers.TempProjectDir); Project p = new Project(new Engine()); BuildItemGroup group = p.AddNewItemGroup(); group.AddNewItem("foos", includePath); object o = p.EvaluatedItems; files.RemoveAt(files.IndexOf(p.EvaluatedItems[0].FinalItemSpec)); p.RemoveItem(p.EvaluatedItems[0]); int i = 0; foreach (string fileName in files) { Assertion.AssertEquals(includePath, group[0].FinalItemSpec); Assertion.AssertEquals(includePath, group[0].Include); Assertion.AssertEquals(fileName, p.EvaluatedItems[i].Include); Assertion.AssertEquals(fileName, p.EvaluatedItems[i].FinalItemSpec); i++; } } finally { CompatibilityTestHelpers.CleanupDirectory(ObjectModelHelpers.TempProjectDir); } }
public void AddTwoNewImportStandard() { string projectPath = String.Empty; string projectPathImport1 = String.Empty; string projectPathImport2 = String.Empty; try { Project p = new Project(new Engine()); projectPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified); projectPathImport1 = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified); projectPathImport2 = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified); p.Load(projectPath); InvokeAddNewImportMethod(p, projectPathImport1, "true"); InvokeAddNewImportMethod(p, projectPathImport2, "true"); Assertion.AssertEquals(0, p.Imports.Count); object o = p.EvaluatedItems; // force evaluation of imported projects. Assertion.AssertEquals(2, CompatibilityTestHelpers.CountNodesWithName(p.Xml, "Import")); // 2 in the XML Assertion.AssertEquals(2, p.Imports.Count); // 2 in OM } finally { CompatibilityTestHelpers.RemoveFile(projectPath); CompatibilityTestHelpers.RemoveFile(projectPathImport1); CompatibilityTestHelpers.RemoveFile(projectPathImport2); } }
public void GetConditionExpression() { Project p = new Project(); p.LoadXml(TestData.ContentUsingTaskFile); Assertion.AssertEquals("$(value)==true", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).Condition); }
public void RemoveImport_ImportOfImport() { string project1 = String.Empty; string importPathA = String.Empty; string importPathB = String.Empty; string importPathBFull = String.Empty; try { project1 = ObjectModelHelpers.CreateFileInTempProjectDirectory("project.proj", TestData.ContentImportA); importPathA = ObjectModelHelpers.CreateFileInTempProjectDirectory("importA.proj", TestData.ContentImportB); importPathB = "importB.proj"; // as specified in TestData.ContentImportB xml importPathBFull = ObjectModelHelpers.CreateFileInTempProjectDirectory(importPathB, TestData.ContentA); Project p = new Project(); p.Load(project1); object o = p.EvaluatedProperties; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPathB); p.Imports.RemoveImport(import); } finally { CompatibilityTestHelpers.RemoveFile(project1); CompatibilityTestHelpers.RemoveFile(importPathA); CompatibilityTestHelpers.RemoveFile(importPathBFull); } }
public void GetEnumerator() { string importPath = String.Empty; string importPath2 = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); importPath2 = ObjectModelHelpers.CreateFileInTempProjectDirectory("import2.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.Imports.AddNewImport(importPath, "true"); p.Imports.AddNewImport(importPath2, "true"); object o = p.EvaluatedItems; Import[] importArray = new Import[p.Imports.Count]; p.Imports.CopyTo(importArray, 0); System.Collections.IEnumerator importEnum = p.Imports.GetEnumerator(); int enumerationCounter = 0; while (importEnum.MoveNext()) { Assertion.AssertEquals(true, object.ReferenceEquals(importArray[enumerationCounter], importEnum.Current)); Assertion.AssertEquals(importArray[enumerationCounter].ProjectPath, ((Import)importEnum.Current).ProjectPath); enumerationCounter++; } } finally { CompatibilityTestHelpers.RemoveFile(importPath); CompatibilityTestHelpers.RemoveFile(importPath2); } }
public void SyncRoot() { string importPath = String.Empty; string importPath2 = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); importPath2 = ObjectModelHelpers.CreateFileInTempProjectDirectory("import2.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.Imports.AddNewImport(importPath, "true"); p.Imports.AddNewImport(importPath2, "true"); object o = p.EvaluatedItems; Import[] importArray = new Import[p.Imports.Count]; p.Imports.CopyTo(importArray, 0); lock (p.Imports.SyncRoot) { int i = 0; foreach (Import import in p.Imports) { Assertion.AssertEquals(importArray[i].ProjectPath, import.ProjectPath); i++; } } } finally { CompatibilityTestHelpers.RemoveFile(importPath); CompatibilityTestHelpers.RemoveFile(importPath2); } }
public void RemoveEvaluatedItem1() { try { List <string> files = CompatibilityTestHelpers.CreateFiles(4, "foo", "foo", ObjectModelHelpers.TempProjectDir); Project p = new Project(new Engine()); BuildItemGroup group = p.AddNewItemGroup(); group.AddNewItem("foos", Path.Combine(ObjectModelHelpers.TempProjectDir, "*.foo")); object o = p.EvaluatedItems; // this causes the failure group.RemoveItem(p.EvaluatedItems[0]); // Exception thrown here Assertion.Fail("success as failure"); // should not get here due to exception above } catch (Exception e) { if (!(e.GetType().ToString().Contains("InternalErrorException"))) { Assertion.Fail(e.Message + " was thrown"); } else { Assertion.Assert("InternalErrorException was thrown", true); } } finally { CompatibilityTestHelpers.CleanupDirectory(ObjectModelHelpers.TempProjectDir); } }
public void GetAssemblyNameScalarThatIsNotSet() { Project p = new Project(new Engine()); p.AddNewUsingTaskFromAssemblyName("TaskName", @"$(assemblyName)"); object o = p.EvaluatedItems; Assertion.AssertEquals(@"$(assemblyName)", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName); }
public void GetAssemblyNameSpecialChars() { Project p = new Project(); p.AddNewUsingTaskFromAssemblyName("TaskName", @"%*?@$();\"); object o = p.EvaluatedItems; Assertion.AssertEquals(@"%*?@$();\", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName); }
public void GetAssemblyNameSpecialCharsEscaped() { Project p = new Project(new Engine()); p.AddNewUsingTaskFromAssemblyName("TaskName", @"%25%2a%3f%40%24%28%29%3b\"); object o = p.EvaluatedItems; Assertion.AssertEquals(@"%25%2a%3f%40%24%28%29%3b\", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName); }
public void GetTaskName_SetInXml() { Project p = new Project(); p.LoadXml(TestData.ContentUsingTaskFile); object o = p.EvaluatedItems; Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks)); }
public void GetConditionSimple() { Project p = new Project(); p.LoadXml(TestData.ContentUsingTaskName); object o = p.EvaluatedProperties; Assertion.AssertEquals("true", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).Condition); }
public void IsImported_false() { Project p = new Project(new Engine()); p.LoadXml(TestData.ContentUsingTaskFile); object o = p.EvaluatedProperties; Assertion.AssertEquals(false, CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).IsImported); }
public void GetTaskNameSpeicalCharsEscaped() { Project p = new Project(new Engine()); p.AddNewUsingTaskFromAssemblyName(@"%25%2a%3f%40%24%28%29%3b\", "assemblyName"); object o = p.EvaluatedItems; Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName(@"%25%2a%3f%40%24%28%29%3b\", p.UsingTasks)); }
public void GetTaskNameSpeicalChars() { Project p = new Project(); p.AddNewUsingTaskFromAssemblyName(@"%*?@$();\", "assemblyName"); object o = p.EvaluatedItems; Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName(@"%*?@$();\", p.UsingTasks)); }
public void GetUsingTaskAssemblyFile_SetInXml() { Project p = new Project(new Engine()); p.LoadXml(TestData.ContentUsingTaskFile); object o = p.EvaluatedItems; Assertion.AssertEquals("AssemblyName.dll", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyFile); }
/// <summary> /// Set an assembly file name, then retrieve it. /// </summary> private string SetandGetAssemblyFileName(string assemblyFileName) { Project p = new Project(); p.AddNewUsingTaskFromAssemblyFile("TaskName", assemblyFileName); object o = p.EvaluatedItems; UsingTask usingTask = CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks); return(usingTask.AssemblyFile); }
public void GetTaskNameScalar() { Project p = new Project(new Engine()); p.AddNewUsingTaskFromAssemblyName("$(name)", "assemblyName"); p.SetProperty("name", "TaskName"); object o = p.EvaluatedItems; Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName("$(name)", p.UsingTasks)); }
public void ToolsetScalar() { Project p = new Project(); p.SetProperty("version", "number"); BuildProperty versionProperty = CompatibilityTestHelpers.FindBuildProperty(p, "version"); p.ParentEngine.Toolsets.Add(new Toolset("scalar", @"$(version)")); object o = p.EvaluatedProperties; Assertion.AssertEquals(false, Object.Equals(versionProperty.Value, p.ParentEngine.Toolsets["scalar"].ToolsVersion)); }
public void GetAssemblyNameScalarEvaluation() { string assemblyName = "$(assemblyName)"; Project p = new Project(); p.SetProperty("assemblyName", "aName"); object o = p.EvaluatedItems; p.AddNewUsingTaskFromAssemblyName("TaskName", assemblyName); o = p.EvaluatedItems; Assertion.AssertEquals(assemblyName, CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName); }
public void AddNewImportFile_EmptyCondition() { string importPath = String.Empty; try { Project p = new Project(new Engine()); importPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.ContentSimpleTools35InitialTargets); InvokeAddNewImportMethod(p, importPath, String.Empty); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void AddNewImportFile_NoReadPermissions() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.ContentSimpleTools35InitialTargets); Project p = new Project(new Engine()); CompatibilityTestHelpers.SetFileAccessPermissions(importPath, FileSystemRights.Read, AccessControlType.Deny); InvokeAddNewImportMethod(p, importPath, null); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void CopyToStrong_ArrayTooSmallImportsNotEvaludated() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.Imports.AddNewImport(importPath, "true"); p.Imports.CopyTo(new Toolset[p.Imports.Count - 1], 0); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void Count_IncrementOnAddFileXml() { string projectPath = String.Empty; try { projectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.ContentUsingTaskFile); Project p = new Project(new Engine()); Assertion.AssertEquals(0, p.UsingTasks.Count); p.Load(projectPath); Assertion.AssertEquals(1, p.UsingTasks.Count); } finally { CompatibilityTestHelpers.RemoveFile(projectPath); } }
public void IsSynchronized() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.Imports.AddNewImport(importPath, "true"); object o = p.EvaluatedItems; Assertion.AssertEquals(false, p.Imports.IsSynchronized); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void AddNewImportFileCondition_False() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.ContentSimpleTools35InitialTargets); Project p = new Project(new Engine()); InvokeAddNewImportMethod(p, importPath, "false"); Assertion.AssertEquals(0, p.Imports.Count); object o = p.EvaluatedItems; // force evaluation of imported projects. Assertion.AssertEquals(0, p.Imports.Count); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void ConditionGet_Null() { string importPath = string.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.AddNewImport(importPath, null); object o = p.EvaluatedProperties; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); Assertion.AssertNull(import.Condition); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }