예제 #1
0
        public void SetupAndTeardownRemotingInfrastructure()
        {
            string configFile = CreateTemporaryConfigurationFile();

            IMock mockCruiseManager = new RemotingMock(typeof(ICruiseManager));
            IMock mockCruiseServer  = new DynamicMock(typeof(ICruiseServer));

            mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance);
            mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance);
            mockCruiseServer.Expect("Dispose");

            using (new RemoteCruiseServer((ICruiseServer)mockCruiseServer.MockInstance, configFile))
            {
                Assert.AreEqual(2, ChannelServices.RegisteredChannels.Length);
                Assert.IsNotNull(ChannelServices.GetChannel("ccnet"), "ccnet channel is missing");
                Assert.IsNotNull(ChannelServices.GetChannel("ccnet2"), "ccnet2 channel is missing");

                ICruiseManager remoteManager = (ICruiseManager)RemotingServices.Connect(typeof(ICruiseManager), "tcp://localhost:35354/" + RemoteCruiseServer.ManagerUri);
                Assert.IsNotNull(remoteManager, "cruiseserver should be registered on tcp channel");

                remoteManager = (ICruiseManager)RemotingServices.Connect(typeof(ICruiseManager), "http://localhost:35355/" + RemoteCruiseServer.ManagerUri);
                Assert.IsNotNull(remoteManager, "cruiseserver should be registered on http channel");
            }
            Assert.AreEqual(0, ChannelServices.RegisteredChannels.Length, "all registered channels should be closed.");
            mockCruiseServer.Verify();
            mockCruiseManager.Verify();
        }
예제 #2
0
        public void HandleServerException()
        {
            RemotingMock cc = new RemotingMock(typeof(ICruiseManager));

            cc.ExpectAndThrow("Run", new Exception("server exception"), new IsAnything(), new IsAnything());

            TcpChannel channel = new TcpChannel(2334);

            using (MockServer server = new MockServer(cc.MarshalByRefInstance, channel, "MockCruise.rem"))
            {
                Runner runner = new Runner();
                runner.Url = "tcp://localhost:2334/MockCruise.rem";
                runner.Run("myProject");
            }
        }
예제 #3
0
        public void ShouldOnlyDisposeOnce()
        {
            string configFile        = CreateTemporaryConfigurationFile();
            IMock  mockCruiseManager = new RemotingMock(typeof(ICruiseManager));
            IMock  mockCruiseServer  = new DynamicMock(typeof(ICruiseServer));

            mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance);
            mockCruiseServer.ExpectAndReturn("CruiseManager", mockCruiseManager.MockInstance);
            mockCruiseServer.Expect("Dispose");

            RemoteCruiseServer server = new RemoteCruiseServer((ICruiseServer)mockCruiseServer.MockInstance, configFile);

            ((IDisposable)server).Dispose();

            mockCruiseServer.ExpectNoCall("Dispose");
            ((IDisposable)server).Dispose();
            mockCruiseServer.Verify();
        }
예제 #4
0
        public void SendScheduleToCruiseManager()
        {
            CollectingConstraint projectNameConstraint = new CollectingConstraint();
            CollectingConstraint scheduleConstraint    = new CollectingConstraint();
            RemotingMock         cc = new RemotingMock(typeof(ICruiseManager));

            cc.Expect("Run", projectNameConstraint, scheduleConstraint);

            using (MockServer server = new MockServer(cc.MarshalByRefInstance, new TcpChannel(2334), "MockCruise.rem"))
            {
                Runner runner = new Runner();
                runner.Url = "tcp://localhost:2334/MockCruise.rem";
                runner.Run("myProject");
            }

            AssertEquals("myProject", projectNameConstraint.Parameter);
            AssertEquals(new Schedule(), scheduleConstraint.Parameter);
            cc.Verify();
        }