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 IsImported_ProjectImportImport() { 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); Assertion.AssertEquals(true, import.IsImported); } finally { CompatibilityTestHelpers.RemoveFile(project1); CompatibilityTestHelpers.RemoveFile(importPathA); CompatibilityTestHelpers.RemoveFile(importPathBFull); } }
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 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 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 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 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 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); } }