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(); }
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"); } }
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(); }
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(); }