public void ExecuteTaskCurrentDirNotEqualExecutionDir()
        {
            string theCurrentDirectory = Directory.GetCurrentDirectory();
            try
            {
                string executionDirectory = "C:\\";
                TaskExecutionMode howToExecuteTask = TaskExecutionMode.InferOutputsOnly;
                XmlDocument doc = new XmlDocument();
                XmlElement taskNode = doc.CreateElement("Foo");
                TaskExecutionStateHelper executionState = new TaskExecutionStateHelper(
                    howToExecuteTask,
                    LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                    LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                    taskNode,
                    hostObject,
                    projectFileOfTaskNode,
                    parentProjectFullFileName,
                    executionDirectory,
                    nodeProxyId);
                executionState.ParentModule = taskExecutionModule;
                executionState.LoggingService = loggingHelper;
                executionState.TargetInferenceSuccessful = true;
                executionState.ExecuteTask();
                Assert.IsTrue(string.Compare(Directory.GetCurrentDirectory(), "C:\\", StringComparison.OrdinalIgnoreCase) == 0, "Expected current directory to be c:\\ which should show up as an empty directory string");
            }
            finally
            {

                Directory.SetCurrentDirectory(theCurrentDirectory);
            }

        }
        public void ExecuteTaskCurrentDirNotEqualExecutionDir()
        {
            string theCurrentDirectory = Directory.GetCurrentDirectory();

            try
            {
                string                   executionDirectory = "C:\\";
                TaskExecutionMode        howToExecuteTask   = TaskExecutionMode.InferOutputsOnly;
                XmlDocument              doc            = new XmlDocument();
                XmlElement               taskNode       = doc.CreateElement("Foo");
                TaskExecutionStateHelper executionState = new TaskExecutionStateHelper(
                    howToExecuteTask,
                    LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                    LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                    taskNode,
                    hostObject,
                    projectFileOfTaskNode,
                    parentProjectFullFileName,
                    executionDirectory,
                    nodeProxyId);
                executionState.ParentModule              = taskExecutionModule;
                executionState.LoggingService            = loggingHelper;
                executionState.TargetInferenceSuccessful = true;
                executionState.ExecuteTask();
                Assert.IsTrue(string.Compare(Directory.GetCurrentDirectory(), "C:\\", StringComparison.OrdinalIgnoreCase) == 0, "Expected current directory to be c:\\ which should show up as an empty directory string");
            }
            finally
            {
                Directory.SetCurrentDirectory(theCurrentDirectory);
            }
        }
        public void TaskExecutionStateTestProperties()
        {
            TaskExecutionMode        howToExecuteTask = TaskExecutionMode.ExecuteTaskAndGatherOutputs;
            XmlDocument              doc            = new XmlDocument();
            XmlElement               taskNode       = doc.CreateElement("Foo");
            TaskExecutionStateHelper executionState = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);

            executionState.HandleId = 1;
            Assert.AreEqual(1, executionState.HandleId, "Expected NodeProxyId to be equal to 1");

            executionState.LoggingService = loggingHelper;
            Assert.AreEqual(loggingHelper, executionState.LoggingService, "Expected LoggingService to be equal to the loggingService set in the LoggingService property setter");
        }
        public void TaskExecutionStateTestProperties()
        {
            TaskExecutionMode howToExecuteTask = TaskExecutionMode.ExecuteTaskAndGatherOutputs;
            XmlDocument doc = new XmlDocument();
            XmlElement taskNode = doc.CreateElement("Foo");
            TaskExecutionStateHelper executionState = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);

            executionState.HandleId = 1;
            Assert.AreEqual(1, executionState.HandleId, "Expected NodeProxyId to be equal to 1");

            executionState.LoggingService = loggingHelper;
            Assert.AreEqual(loggingHelper, executionState.LoggingService, "Expected LoggingService to be equal to the loggingService set in the LoggingService property setter");
        }
        private List <TaskExecutionStateHelper> InitializeTaskState()
        {
            BuildPropertyGroup projectLevelProprtiesForInference;
            BuildPropertyGroup projectLevelPropertiesForExecution;

            Hashtable[] inferenceBucketItemsByName;
            Hashtable[] inferenceBucketMetaData;
            Hashtable   projectLevelItemsForInference;

            Hashtable[] executionBucketItemsByName;
            Hashtable[] executionBucketMetaData;
            Hashtable   projectLevelItemsForExecution;
            ITaskHost   hostObject;
            EngineLoggingServicesHelper loggingHelper;
            string projectFileOfTaskNode;
            string parentProjectFullFileName;
            int    nodeProxyId;
            int    projectId;
            string executionDirectory;

            XmlElement taskNode  = new XmlDocument().CreateElement("MockTask");
            LoadedType taskClass = new LoadedType(typeof(MockTask), new AssemblyLoadInfo(typeof(MockTask).Assembly.FullName, null));

            loggingHelper          = new EngineLoggingServicesHelper();
            engine.LoggingServices = loggingHelper;
            Project project = new Project(engine);

            nodeProxyId = engine.EngineCallback.CreateTaskContext(project, null, null, taskNode, EngineCallback.inProcNode, new BuildEventContext(BuildEventContext.InvalidNodeId, BuildEventContext.InvalidTargetId, BuildEventContext.InvalidProjectContextId, BuildEventContext.InvalidTaskId));
            // Set up some "fake data" which will be passed to the Task Execution State object
            Hashtable[] fakeArray = new Hashtable[1];
            fakeArray[0] = new Hashtable();
            projectLevelProprtiesForInference  = new BuildPropertyGroup();
            projectLevelPropertiesForExecution = new BuildPropertyGroup();
            inferenceBucketItemsByName         = fakeArray;
            inferenceBucketMetaData            = fakeArray;
            projectLevelItemsForInference      = new Hashtable();
            executionBucketItemsByName         = fakeArray;
            executionBucketMetaData            = fakeArray;
            projectLevelItemsForExecution      = new Hashtable();
            hostObject                = null;
            projectFileOfTaskNode     = "In Memory";
            parentProjectFullFileName = project.FullFileName;

            executionDirectory = Directory.GetCurrentDirectory();
            projectId          = project.Id;


            MockTaskExecutionModule taskExecutionModule = taskExecutionModule = new MockTaskExecutionModule(new EngineCallback(engine));
            TaskExecutionMode       howToExecuteTask    = TaskExecutionMode.InferOutputsOnly;

            List <TaskExecutionStateHelper> executionStates = new List <TaskExecutionStateHelper>();

            TaskExecutionStateHelper executionStateNormal1 = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);

            executionStateNormal1.LoggingService            = loggingHelper;
            executionStateNormal1.TargetInferenceSuccessful = true;
            executionStateNormal1.ParentModule = taskExecutionModule;

            executionStates.Add(executionStateNormal1);


            TaskExecutionStateHelper executionStateCallBack = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);

            executionStateCallBack.LoggingService            = loggingHelper;
            executionStateCallBack.TargetInferenceSuccessful = true;

            executionStates.Add(executionStateCallBack);


            TaskExecutionStateHelper executionStateNormal2 = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);

            executionStateNormal2.LoggingService            = loggingHelper;
            executionStateNormal2.TargetInferenceSuccessful = true;
            executionStateNormal2.ParentModule = taskExecutionModule;
            executionStates.Add(executionStateNormal2);

            TaskExecutionStateHelper executionStateNormal3 = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);

            executionStateNormal3.LoggingService            = loggingHelper;
            executionStateNormal3.TargetInferenceSuccessful = true;
            executionStateNormal3.ParentModule = taskExecutionModule;
            executionStates.Add(executionStateNormal3);

            return(executionStates);
        }
Example #6
0
        private List<TaskExecutionStateHelper> InitializeTaskState()
        {
            BuildPropertyGroup projectLevelProprtiesForInference;
            BuildPropertyGroup projectLevelPropertiesForExecution;
            Hashtable[] inferenceBucketItemsByName;
            Hashtable[] inferenceBucketMetaData;
            Hashtable projectLevelItemsForInference;
            Hashtable[] executionBucketItemsByName;
            Hashtable[] executionBucketMetaData;
            Hashtable projectLevelItemsForExecution;
            ITaskHost hostObject;
            EngineLoggingServicesHelper loggingHelper;
            string projectFileOfTaskNode;
            string parentProjectFullFileName;
            int nodeProxyId;
            int projectId;
            string executionDirectory;

            XmlElement taskNode = new XmlDocument().CreateElement("MockTask");
            LoadedType taskClass = new LoadedType(typeof(MockTask), new AssemblyLoadInfo(typeof(MockTask).Assembly.FullName, null));
            loggingHelper = new EngineLoggingServicesHelper();
            engine.LoggingServices = loggingHelper;
            Project project = new Project(engine);

            nodeProxyId = engine.EngineCallback.CreateTaskContext(project, null, null, taskNode, EngineCallback.inProcNode, new BuildEventContext(BuildEventContext.InvalidNodeId, BuildEventContext.InvalidTargetId, BuildEventContext.InvalidProjectContextId, BuildEventContext.InvalidTaskId));
            // Set up some "fake data" which will be passed to the Task Execution State object
            Hashtable[] fakeArray = new Hashtable[1];
            fakeArray[0] = new Hashtable();
            projectLevelProprtiesForInference = new BuildPropertyGroup();
            projectLevelPropertiesForExecution = new BuildPropertyGroup();
            inferenceBucketItemsByName = fakeArray;
            inferenceBucketMetaData = fakeArray;
            projectLevelItemsForInference = new Hashtable();
            executionBucketItemsByName = fakeArray;
            executionBucketMetaData = fakeArray;
            projectLevelItemsForExecution = new Hashtable();
            hostObject = null;
            projectFileOfTaskNode = "In Memory";
            parentProjectFullFileName = project.FullFileName;

            executionDirectory = Directory.GetCurrentDirectory();
            projectId = project.Id;


            MockTaskExecutionModule taskExecutionModule = taskExecutionModule = new MockTaskExecutionModule(new EngineCallback(engine));
            TaskExecutionMode howToExecuteTask = TaskExecutionMode.InferOutputsOnly;

            List<TaskExecutionStateHelper> executionStates = new List<TaskExecutionStateHelper>();

            TaskExecutionStateHelper executionStateNormal1 = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);
            executionStateNormal1.LoggingService = loggingHelper;
            executionStateNormal1.TargetInferenceSuccessful = true;
            executionStateNormal1.ParentModule = taskExecutionModule;

            executionStates.Add(executionStateNormal1);


            TaskExecutionStateHelper executionStateCallBack = new TaskExecutionStateHelper(
                howToExecuteTask,
                LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
                LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
                taskNode,
                hostObject,
                projectFileOfTaskNode,
                parentProjectFullFileName,
                executionDirectory,
                nodeProxyId);
            executionStateCallBack.LoggingService = loggingHelper;
            executionStateCallBack.TargetInferenceSuccessful = true;

            executionStates.Add(executionStateCallBack);


            TaskExecutionStateHelper executionStateNormal2 = new TaskExecutionStateHelper(
               howToExecuteTask,
               LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
               LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
               taskNode,
               hostObject,
               projectFileOfTaskNode,
               parentProjectFullFileName,
               executionDirectory,
               nodeProxyId);
            executionStateNormal2.LoggingService = loggingHelper;
            executionStateNormal2.TargetInferenceSuccessful = true;
            executionStateNormal2.ParentModule = taskExecutionModule;
            executionStates.Add(executionStateNormal2);

            TaskExecutionStateHelper executionStateNormal3 = new TaskExecutionStateHelper(
              howToExecuteTask,
              LookupHelpers.CreateLookup(projectLevelProprtiesForInference, projectLevelItemsForInference),
              LookupHelpers.CreateLookup(projectLevelPropertiesForExecution, projectLevelItemsForExecution),
              taskNode,
              hostObject,
              projectFileOfTaskNode,
              parentProjectFullFileName,
              executionDirectory,
              nodeProxyId);
            executionStateNormal3.LoggingService = loggingHelper;
            executionStateNormal3.TargetInferenceSuccessful = true;
            executionStateNormal3.ParentModule = taskExecutionModule;
            executionStates.Add(executionStateNormal3);

            return executionStates;
        }