Example #1
0
        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);
            }
        }
Example #2
0
        public void GetUsingTaskCondition_SetInXml()
        {
            Project p = new Project();

            p.LoadXml(TestData.ContentUsingTaskName);
            Assertion.AssertEquals("true", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).Condition);
        }
Example #3
0
        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);
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
 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);
     }
 }
Example #6
0
 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);
     }
 }
Example #7
0
        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);
            }
        }
Example #8
0
        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);
            }
        }
Example #9
0
        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);
            }
        }
Example #10
0
        public void GetConditionExpression()
        {
            Project p = new Project();

            p.LoadXml(TestData.ContentUsingTaskFile);
            Assertion.AssertEquals("$(value)==true", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).Condition);
        }
Example #11
0
        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));
        }
Example #12
0
        public void GetTaskNameSpeicalChars()
        {
            Project p = new Project();

            p.AddNewUsingTaskFromAssemblyName(@"%*?@$();\", "assemblyName");
            object o = p.EvaluatedItems;

            Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName(@"%*?@$();\", p.UsingTasks));
        }
Example #13
0
        public void GetAssemblyNameSpecialChars()
        {
            Project p = new Project();

            p.AddNewUsingTaskFromAssemblyName("TaskName", @"%*?@$();\");
            object o = p.EvaluatedItems;

            Assertion.AssertEquals(@"%*?@$();\", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName);
        }
Example #14
0
        public void GetTaskName_SetInXml()
        {
            Project p = new Project();

            p.LoadXml(TestData.ContentUsingTaskFile);
            object o = p.EvaluatedItems;

            Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks));
        }
Example #15
0
        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);
        }
Example #16
0
        public void GetConditionSimple()
        {
            Project p = new Project();

            p.LoadXml(TestData.ContentUsingTaskName);
            object o = p.EvaluatedProperties;

            Assertion.AssertEquals("true", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).Condition);
        }
Example #17
0
        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);
        }
Example #18
0
        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);
        }
Example #19
0
        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);
        }
Example #20
0
        /// <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);
        }
Example #21
0
        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));
        }
Example #22
0
        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);
        }
Example #23
0
        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));
        }
Example #24
0
        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);
            }
        }
Example #25
0
        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);
            }
        }
Example #26
0
        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);
            }
        }
Example #27
0
        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);
            }
        }
Example #28
0
        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);
            }
        }
Example #29
0
        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);
            }
        }
Example #30
0
        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);
            }
        }