예제 #1
0
        public void TestValidHostObjectRegistration()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();
            TestHostObject hostObject2  = new TestHostObject();
            TestHostObject hostObject3  = new TestHostObject();

            hostServices.RegisterHostObject("foo.proj", "target", "task", hostObject);
            hostServices.RegisterHostObject("foo.proj", "target2", "task", hostObject2);
            hostServices.RegisterHostObject("foo.proj", "target", "task2", hostObject3);

            Assert.Same(hostObject, hostServices.GetHostObject("foo.proj", "target", "task"));
            Assert.Same(hostObject2, hostServices.GetHostObject("foo.proj", "target2", "task"));
            Assert.Same(hostObject3, hostServices.GetHostObject("foo.proj", "target", "task2"));
        }
예제 #2
0
        public void TestUnregisteringNonConflictingHostObjectRestoresOriginalAffinity()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.SetNodeAffinity(String.Empty, NodeAffinity.OutOfProc);
            hostServices.SetNodeAffinity("project", NodeAffinity.Any);
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project2"));
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project"));

            hostServices.RegisterHostObject("project", "target", "task", hostObject);
            Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project"));
            hostServices.RegisterHostObject("project", "target", "task", hostObject: null);
            Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project"));
            Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project2"));
        }
예제 #3
0
        public void TestNoContradictoryRemoteHostObjectAffinity()
        {
            HostServices hostServices = new HostServices();

            hostServices.RegisterHostObject("project", "target", "task", "moniker");
            hostServices.SetNodeAffinity("project", NodeAffinity.Any);
        }
예제 #4
0
        public void TestInvalidHostObjectRegistration_NullTask()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.RegisterHostObject("project", "target", null, hostObject);
        }
예제 #5
0
        public void TestNonContraditcoryHostObjectAllowed_InProc()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.SetNodeAffinity("project", NodeAffinity.InProc);
            hostServices.RegisterHostObject("project", "target", "task", hostObject);
        }
예제 #6
0
        public void TestRegisterRemoteHostObjectNoAffect_Any2()
        {
            HostServices hostServices = new HostServices();

            hostServices.SetNodeAffinity("project", NodeAffinity.Any);
            hostServices.RegisterHostObject("project", "target", "task", "moniker");
            hostServices.GetNodeAffinity("project").ShouldBe(NodeAffinity.Any);
        }
예제 #7
0
        public void TestHostObjectCausesInProcAffinity()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.RegisterHostObject("project", "target", "task", hostObject);
            Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project"));
        }
예제 #8
0
        public void TestContraditcoryHostObjectCausesException_OutOfProc()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc);
            hostServices.RegisterHostObject("project", "target", "task", hostObject);
        }
예제 #9
0
        public void TestNonContraditcoryHostObjectAllowed_Any()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.SetNodeAffinity("project", NodeAffinity.Any);
            hostServices.RegisterHostObject("project", "target", "task", hostObject);
            Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project"));
        }
예제 #10
0
        public void TestContradictoryAffinityCausesException_Any()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.RegisterHostObject("project", "target", "task", hostObject);
            Assert.AreEqual(NodeAffinity.InProc, hostServices.GetNodeAffinity("project"));
            hostServices.SetNodeAffinity("project", NodeAffinity.Any);
        }
예제 #11
0
 public void TestInvalidHostObjectRegistration_NullTask()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         HostServices hostServices = new HostServices();
         TestHostObject hostObject = new TestHostObject();
         hostServices.RegisterHostObject("project", "target", null, hostObject);
     }
                                           );
 }
예제 #12
0
 public void TestContraditcoryHostObjectCausesException_OutOfProc()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         HostServices hostServices = new HostServices();
         TestHostObject hostObject = new TestHostObject();
         hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc);
         hostServices.RegisterHostObject("project", "target", "task", hostObject);
     }
                                               );
 }
        private void SetHostObject()
        {
            HostServices services = new HostServices();

            foreach (string projectName in ProjectNames)
            {
                if (projectName != null)
                {
                    services.RegisterHostObject(projectName, "AfterBuild", "ScannerTask", Factory.GetScannerHost());
                }
            }

            ProjectCollection.GlobalProjectCollection.HostServices = services;
        }
예제 #14
0
        public void UnloadedProjectDiscardsHostServicesAllProjects()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject th           = new TestHostObject();

            ProjectCollection.GlobalProjectCollection.HostServices = hostServices;
            Project project = LoadDummyProject("foo.proj");

            hostServices.RegisterHostObject(project.FullPath, "test", "Message", th);

            ProjectCollection.GlobalProjectCollection.UnloadAllProjects();

            Assert.False(hostServices.HasInProcessHostObject(project.FullPath));
        }
예제 #15
0
        public void TestTranslationRemoteHostObjects()
        {
            var stateInHostObject = 3;

            var hostServices = new HostServices();
            var rot          = new MockRunningObjectTable();

            hostServices.SetTestRunningObjectTable(rot);
            var moniker    = nameof(TestTranslationRemoteHostObjects) + Guid.NewGuid();
            var remoteHost = new MockRemoteHostObject(stateInHostObject);

            using (var result = rot.Register(moniker, remoteHost))
            {
                hostServices.RegisterHostObject(
                    "WithOutOfProc.targets",
                    "DisplayMessages",
                    "ATask",
                    moniker);

                BuildRequest request = new BuildRequest(
                    submissionId: 1,
                    _nodeRequestId++,
                    1,
                    new string[] { "alpha", "omega" },
                    hostServices: hostServices,
                    BuildEventContext.Invalid,
                    parentRequest: null);

                ((ITranslatable)request).Translate(TranslationHelpers.GetWriteTranslator());
                INodePacket packet = BuildRequest.FactoryForDeserialization(TranslationHelpers.GetReadTranslator());

                BuildRequest deserializedRequest = packet as BuildRequest;
                deserializedRequest.HostServices.SetTestRunningObjectTable(rot);
                var hostObject = deserializedRequest.HostServices.GetHostObject(
                    "WithOutOfProc.targets",
                    "DisplayMessages",
                    "ATask") as ITestRemoteHostObject;

                hostObject.GetState().ShouldBe(stateInHostObject);
            }
        }