diff options
author | Jon Skeet <skeet@pobox.com> | 2009-06-25 09:18:02 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2009-06-25 09:18:02 +0100 |
commit | b2526215e107f64c66804403667aabaa042a67db (patch) | |
tree | 5b976fe9b25308521988152f777c8abbe8b24358 | |
parent | 37a7983aaae11d52408803f7a99a894183bfeb9e (diff) | |
download | protobuf-b2526215e107f64c66804403667aabaa042a67db.tar.gz protobuf-b2526215e107f64c66804403667aabaa042a67db.tar.bz2 protobuf-b2526215e107f64c66804403667aabaa042a67db.zip |
Use remoting mocks to work with mono
-rw-r--r-- | src/ProtocolBuffers.Test/ServiceTest.cs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/ProtocolBuffers.Test/ServiceTest.cs b/src/ProtocolBuffers.Test/ServiceTest.cs index 8d14f0c3..c6899076 100644 --- a/src/ProtocolBuffers.Test/ServiceTest.cs +++ b/src/ProtocolBuffers.Test/ServiceTest.cs @@ -71,7 +71,7 @@ namespace Google.ProtocolBuffers { MockRepository mocks = new MockRepository(); FooRequest fooRequest = FooRequest.CreateBuilder().Build(); FooResponse fooResponse = FooResponse.CreateBuilder().Build(); - IRpcController controller = mocks.StrictMock<IRpcController>(); + IRpcController controller = mocks.StrictMockWithRemoting<IRpcController>(); bool fooCalled = false; @@ -110,10 +110,16 @@ namespace Google.ProtocolBuffers { public void GeneratedStubFooCall() { FooRequest fooRequest = FooRequest.CreateBuilder().Build(); MockRepository mocks = new MockRepository(); - IRpcChannel mockChannel = mocks.StrictMock<IRpcChannel>(); - IRpcController mockController = mocks.StrictMock<IRpcController>(); + IRpcChannel mockChannel = mocks.StrictMockWithRemoting<IRpcChannel>(); + IRpcController mockController = mocks.StrictMockWithRemoting<IRpcController>(); TestService service = TestService.CreateStub(mockChannel); - Action<FooResponse> doneHandler = mocks.StrictMock<Action<FooResponse>>(); + bool doneCalled = false; + // TODO(jonskeet): Use Rhino for this (to get ordering) when Mono works with it properly + Action<FooResponse> doneHandler = response => { + Assert.IsFalse(doneCalled); + doneCalled = true; + Assert.AreEqual(FooResponse.DefaultInstance, response); + }; using (mocks.Record()) { @@ -123,7 +129,6 @@ namespace Google.ProtocolBuffers { .Constraints(Is.Same(FooDescriptor), Is.Same(mockController), Is.Same(fooRequest), Is.Same(FooResponse.DefaultInstance), Is.Anything()) .Do((CallFooDelegate) ((p1, p2, p3, response, done) => done(response))); - doneHandler.Invoke(FooResponse.DefaultInstance); } service.Foo(mockController, fooRequest, doneHandler); @@ -136,7 +141,7 @@ namespace Google.ProtocolBuffers { MockRepository mocks = new MockRepository(); BarRequest barRequest = BarRequest.CreateBuilder().Build(); BarResponse barResponse = BarResponse.CreateBuilder().Build(); - IRpcController controller = mocks.StrictMock<IRpcController>(); + IRpcController controller = mocks.StrictMockWithRemoting<IRpcController>(); bool barCalled = false; |