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 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 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 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 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 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 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 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); } }
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 IsImported_true() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.ContentUsingTaskName); Project p = new Project(new Engine()); p.AddNewImport(importPath, "true"); Object o = p.EvaluatedProperties; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); import.Condition = null; Assertion.AssertEquals(true, CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).IsImported); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void AddNewImportToBecomeSelfReferentialTwice() { string projectPath = String.Empty; try { Project p = new Project(new Engine()); projectPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified); InvokeAddNewImportMethod(p, projectPath, null); InvokeAddNewImportMethod(p, projectPath, null); object o = p.EvaluatedItems; // force evaluation of imported projects. Assertion.AssertEquals(1, p.Imports.Count); Assertion.AssertEquals(2, CompatibilityTestHelpers.CountNodesWithName(p.Xml, "Import")); // 2 in the XML } finally { CompatibilityTestHelpers.RemoveFile(projectPath); } }
public void AddNewImportToBecomeSelfReferential() { string projectPath = String.Empty; try { Project p = new Project(new Engine()); projectPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified); p.Load(projectPath); InvokeAddNewImportMethod(p, projectPath, "true"); Assertion.AssertEquals(0, p.Imports.Count); object o = p.EvaluatedItems; // force evaluation of imported projects. Assertion.AssertEquals(0, p.Imports.Count); // This is bonkers, should be 1 because the XML DOES contain the import node. } finally { CompatibilityTestHelpers.RemoveFile(projectPath); } }
public void AddNewImportAttributeprecedence_DefaultTarget() { string importPath = String.Empty; try { Project p = new Project(new Engine()); p.DefaultTargets = "localTargetDefault"; importPath = ObjectModelHelpers.CreateTempFileOnDisk(TestData.Content3SimpleTargetsDefaultSpecified); // TestTargetDefault InvokeAddNewImportMethod(p, importPath, null); Assertion.AssertEquals("localTargetDefault", p.DefaultTargets); // Assert non automatic evaluation. object o = p.EvaluatedItems; // force evaluation of imported projects. Assertion.AssertEquals("localTargetDefault", p.DefaultTargets); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void ProjectPathSet_Escaped() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.AddNewImport(importPath, "true"); object o = p.EvaluatedProperties; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); import.ProjectPath = @"%25%2a%3f%40%24%28%29%3b\"; Assertion.AssertEquals(@"%25%2a%3f%40%24%28%29%3b\", import.ProjectPath); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void ProjectPathGetWhenSetInCtor() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.AddNewImport(importPath, "true"); object o = p.EvaluatedProperties; // The verbosity of this assertion is to abstract the internal implentation of FindFirstMatchingImportByPath. Assertion.AssertEquals(importPath, CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath).ProjectPath); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void Count_DecrementOnRemove() { 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(1, p.Imports.Count); p.Imports.RemoveImport(CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath)); Assertion.AssertEquals(0, p.Imports.Count); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void EvaluatedProjectPathGetWhenSetInCtor() { string importPath = "importA.proj"; string fullImportPath = ObjectModelHelpers.CreateFileInTempProjectDirectory(importPath, TestData.Content3SimpleTargetsDefaultSpecified); string projectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("project.proj", TestData.ContentImportA); try { Project p = new Project(); p.Load(projectPath); // The verbosity of this assertion is to abstract the internal implentation of FindFirstMatchingImportByPath. Assertion.AssertEquals(fullImportPath, CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath).EvaluatedProjectPath); } finally { CompatibilityTestHelpers.RemoveFile(projectPath); CompatibilityTestHelpers.RemoveFile(fullImportPath); } }
public void ImportsUsingTask() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.Save(importPath); // required to reproduce importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.ContentUsingTaskFile); Project p2 = new Project(); // new Engine() here fixes testcase p2.AddNewImport(importPath, "true"); object o = p2.EvaluatedProperties; // evaluate the import Assertion.AssertNull(CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p2.UsingTasks)); // fails to find task } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void CopyToWeak_Simple() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(new Engine()); p.Imports.AddNewImport(importPath, "true"); object o = p.EvaluatedItems; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); Array importArray = Array.CreateInstance(typeof(Import), p.Imports.Count); p.Imports.CopyTo(importArray, 0); Assertion.AssertEquals(p.Imports.Count, importArray.Length); Assertion.AssertEquals(0, Array.IndexOf(importArray, import)); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void ProjectPathGetWhenSetInXML() { string projectPath = String.Empty; string importPath = String.Empty; string fullImportPath = String.Empty; try { projectPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("project.proj", TestData.ContentImportA); importPath = "importA.proj"; // as specified in xml fullImportPath = ObjectModelHelpers.CreateFileInTempProjectDirectory(importPath, TestData.ContentA); Project p = new Project(); p.Load(projectPath); Assertion.AssertEquals(importPath, CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath).ProjectPath); } finally { CompatibilityTestHelpers.RemoveFile(projectPath); CompatibilityTestHelpers.RemoveFile(fullImportPath); } }
public void RemoveImport_Empty() { string importPath = String.Empty; try { importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); Project p2 = new Project(); p.Imports.AddNewImport(importPath, "true"); p2.Imports.AddNewImport(importPath, "true"); object o = p.EvaluatedItems; o = p2.EvaluatedItems; Import import2 = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p2.Imports, importPath); p.Imports.RemoveImport(import2); // does not exist in this project } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void CopyToStrong_IndexZero() { 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; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); Import[] importArray = new Import[p.Imports.Count]; p.Imports.CopyTo(importArray, 0); Assertion.AssertEquals(p.Imports.Count, importArray.Length); Assertion.AssertEquals(0, Array.IndexOf(importArray, import)); Assertion.AssertEquals(true, object.ReferenceEquals(importArray[Array.IndexOf(importArray, import)], import)); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }
public void CopyToStrong_OffsetIndex() { string importPath = String.Empty; try { const int OffsetIndex = 2; importPath = ObjectModelHelpers.CreateFileInTempProjectDirectory("import.proj", TestData.Content3SimpleTargetsDefaultSpecified); Project p = new Project(); p.Imports.AddNewImport(importPath, "true"); object o = p.EvaluatedItems; Import import = CompatibilityTestHelpers.FindFirstMatchingImportByPath(p.Imports, importPath); Import[] importArray = new Import[p.Imports.Count + OffsetIndex]; p.Imports.CopyTo(importArray, OffsetIndex); Assertion.AssertEquals(p.Imports.Count, importArray.Length - OffsetIndex); Assertion.AssertNull(importArray[OffsetIndex - 1]); Assertion.AssertEquals(true, 0 < Array.IndexOf(importArray, import)); } finally { CompatibilityTestHelpers.RemoveFile(importPath); } }