Exemplo n.º 1
0
        public void TestUnregisterHostObject()
        {
            HostServices   hostServices = new HostServices();
            TestHostObject hostObject   = new TestHostObject();

            hostServices.RegisterHostObject("project", "target", "task", hostObject);
            Assert.Same(hostObject, hostServices.GetHostObject("project", "target", "task"));

            hostServices.RegisterHostObject("project", "target", "task", hostObject: null);
            Assert.Null(hostServices.GetHostObject("project", "target", "task"));
        }
Exemplo n.º 2
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"));
        }
Exemplo n.º 3
0
        public void TestRegisterOverrideExistingRegisted()
        {
            var hostServices = new HostServices();
            var rot          = new MockRunningObjectTable();

            hostServices.SetTestRunningObjectTable(rot);

            var moniker    = Guid.NewGuid().ToString();
            var remoteHost = new MockRemoteHostObject(1);

            rot.Register(moniker, remoteHost);
            var newMoniker    = Guid.NewGuid().ToString();
            var newRemoteHost = new MockRemoteHostObject(2);

            rot.Register(newMoniker, newRemoteHost);
            hostServices.RegisterHostObject(
                "WithOutOfProc.targets",
                "DisplayMessages",
                "ATask",
                remoteHost);

            hostServices.RegisterHostObject("project", "test", "Message", moniker);
            hostServices.RegisterHostObject("project", "test", "Message", newMoniker);
            var resultObject = (ITestRemoteHostObject)hostServices.GetHostObject("project", "test", "Message");

            resultObject.GetState().ShouldBe(2);
        }