Пример #1
0
        public void GenerateMockFromInterface()
        {
            RemotingMock       mock     = new RemotingMock(typeof(Base));
            MarshalByRefObject instance = mock.MarshalByRefInstance;

            AssertNotNull(instance);
        }
		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();
		}
Пример #3
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");
			}
		}
Пример #4
0
		public void MarshalRemotingMock()
		{
			RemotingMock mock = new RemotingMock(typeof(Foo));
			mock.Expect("Bar");

			TcpChannel channel = new TcpChannel(1234);
			using (MockServer server = new MockServer(mock.MarshalByRefInstance, channel, "mock.rem"))
			{
				Foo foo = (Foo)RemotingServices.Connect(typeof(Foo), "tcp://localhost:1234/mock.rem");
				foo.Bar();
			}

			mock.Verify();
		}
Пример #5
0
        public void MarshalRemotingMock()
        {
            RemotingMock mock = new RemotingMock(typeof(Foo));

            mock.Expect("Bar");

            TcpChannel channel = new TcpChannel(1234);

            using (MockServer server = new MockServer(mock.MarshalByRefInstance, channel, "mock.rem"))
            {
                Foo foo = (Foo)RemotingServices.Connect(typeof(Foo), "tcp://localhost:1234/mock.rem");
                foo.Bar();
            }

            mock.Verify();
        }
		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();
		}
Пример #7
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();
		}
Пример #8
0
		public void GenerateMockFromInterface()
		{
			RemotingMock mock = new RemotingMock(typeof(Base));
			MarshalByRefObject instance = mock.MarshalByRefInstance;
			AssertNotNull(instance);
		}