Esempio n. 1
0
        public void RegisterMultipleTasksSomeWithSameName()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           "CustomTask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",           null),
                                          new UsingTaskInfo("YetAnotherCustomTask", "YetAnotherCustomTask, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("CustomTask",           "CustomTask, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null",           null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            //First assert that there are two unique buckets
            Assert.AreEqual(2, registryStub.AllTaskDeclarations.Count, "Expected only two buckets since two of three tasks have the same name!");

            //Now let's look at the bucket with only one task
            ArrayList singletonBucket = (ArrayList)registryStub.AllTaskDeclarations[taskInfos[1].TaskName];

            Assert.IsNotNull(singletonBucket, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
            Assert.AreEqual(1, singletonBucket.Count, "Expected only one AssemblyLoadInfo registered under this TaskName!");
            AssemblyLoadInfo singletonAssemblyLoadInfo = (AssemblyLoadInfo)singletonBucket[0];

            Assert.AreEqual(singletonAssemblyLoadInfo, taskInfos[1].AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");

            //Finally let's look at the bucket with two tasks
            ArrayList duplicateBucket = (ArrayList)registryStub.AllTaskDeclarations[taskInfos[0].TaskName];

            Assert.IsNotNull(duplicateBucket, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
            Assert.AreEqual(2, duplicateBucket.Count, "Expected two AssemblyLoadInfos registered under this TaskName!");
            bool bothTaskVersionsFound = duplicateBucket.Contains(taskInfos[0].AssemblyInfo) && duplicateBucket.Contains(taskInfos[2].AssemblyInfo);

            Assert.IsTrue(bothTaskVersionsFound, "Expected both versions of the task to be registered in this bucket!");
        }
Esempio n. 2
0
        public void RegisterMultipleTasksWithSameNameAndSameAssembly()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           null,                                                                          "Some\\Relative\\Path\\CustomTasks.dll"),
                                          new UsingTaskInfo("YetAnotherCustomTask", "YetAnotherCustomTask, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("CustomTask",           null,                                                                          "Some\\Relative\\Path\\CustomTasks.dll") };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            //two unique buckets
            Assert.AreEqual(2, registryStub.AllTaskDeclarations.Count, "Expected only two buckets since two of three tasks have the same name!");
            //three total tasks
            Assert.AreEqual(3, TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations), "Expected three total tasks registered in TaskRegistry!");
        }
Esempio n. 3
0
        public void TasksNoLongerRegisteredAfterClearCalled()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           "CustomTask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",           null),
                                          new UsingTaskInfo("YetAnotherCustomTask", "YetAnotherCustomTask, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("MyCustomTask",         "CustomTask, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null",           null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(3, registeredTaskCount, "Expected three registered tasks in TaskRegistry.AllTaskDeclarations!");

            registryStub.Clear();

            registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);
            Assert.AreEqual(0, registeredTaskCount, "Expected no registered tasks in TaskRegistry.AllTaskDeclarations!");
        }
Esempio n. 4
0
        public void RegisterTaskSimple()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask", "CustomTask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(1, registeredTaskCount, "Expected only one registered task in TaskRegistry.AllTaskDeclarations!");

            ArrayList taskAssemblyLoadInfoList = (ArrayList)registryStub.AllTaskDeclarations[taskInfos[0].TaskName];

            Assert.IsNotNull(taskAssemblyLoadInfoList, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
            Assert.AreEqual(1, taskAssemblyLoadInfoList.Count, "Expected only one AssemblyLoadInfo registered!");

            AssemblyLoadInfo taskAssemblyLoadInfo = (AssemblyLoadInfo)taskAssemblyLoadInfoList[0];

            Assert.AreEqual(taskAssemblyLoadInfo, taskInfos[0].AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");
        }
Esempio n. 5
0
        public void RegisterMultipleTasksWithDifferentNamesFromSameAssembly()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           "CustomTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("YetAnotherCustomTask", null,                                                                 "bin\\Assemblies\\YetAnotherCustomTask.dll"),
                                          new UsingTaskInfo("AnotherCustomTask",    "CustomTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(3, registeredTaskCount, "Expected three registered tasks in TaskRegistry.AllTaskDeclarations!");

            foreach (UsingTaskInfo taskInfo in taskInfos)
            {
                ArrayList taskAssemblyLoadInfoList = (ArrayList)registryStub.AllTaskDeclarations[taskInfo.TaskName];
                Assert.IsNotNull(taskAssemblyLoadInfoList, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
                Assert.AreEqual(1, taskAssemblyLoadInfoList.Count, "Expected only one AssemblyLoadInfo registered under this TaskName!");

                AssemblyLoadInfo taskAssemblyLoadInfo = (AssemblyLoadInfo)taskAssemblyLoadInfoList[0];
                Assert.AreEqual(taskAssemblyLoadInfo, taskInfo.AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");
            }
        }
Esempio n. 6
0
        public void AllUsingTaskAttributesAreExpanded()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("$(Property1)@(ThirdItem)$(Property2)", null,                                                                              "Some\\$(Property3)\\Path\\CustomTasks.dll"),
                                          new UsingTaskInfo("YetAnotherCustomTask",                 "$(Property4)@(ThirdItem), Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("Custom$(Property5)Task",               null,                                                                              "Some\\Relative\\Path\\CustomTasks.dll", "'@(ThirdItem)$(Property1)' == 'ThirdValue1Value1'") };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(3, registeredTaskCount, "Expected three registered tasks in TaskRegistry.AllTaskDeclarations!");

            foreach (UsingTaskInfo taskInfo in taskInfos)
            {
                UsingTaskInfo expandedTaskInfo         = taskInfo.CopyAndExpand(TaskRegistryHelperMethods.RegistryExpander);
                ArrayList     taskAssemblyLoadInfoList = (ArrayList)registryStub.AllTaskDeclarations[expandedTaskInfo.TaskName];
                Assert.IsNotNull(taskAssemblyLoadInfoList, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
                Assert.AreEqual(1, taskAssemblyLoadInfoList.Count, "Expected only one AssemblyLoadInfo registered under this TaskName!");

                AssemblyLoadInfo taskAssemblyLoadInfo = (AssemblyLoadInfo)taskAssemblyLoadInfoList[0];
                Assert.AreEqual(taskAssemblyLoadInfo, expandedTaskInfo.AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");
            }
        }