diff options
author | csharptest <roger@csharptest.net> | 2011-05-19 12:01:16 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-05-19 12:01:16 -0500 |
commit | f1816beebe7f68a6e9380b964d93c1dee91fb277 (patch) | |
tree | c03f8e2d549a7ed71e243a1437085b9d7c976f42 /src/ProtocolBuffers.Test/ServiceTest.cs | |
parent | 68d831e3a48ea3a81b3791a24219bc3406b962b8 (diff) | |
download | protobuf-f1816beebe7f68a6e9380b964d93c1dee91fb277.tar.gz protobuf-f1816beebe7f68a6e9380b964d93c1dee91fb277.tar.bz2 protobuf-f1816beebe7f68a6e9380b964d93c1dee91fb277.zip |
- Added CSharpServiceType NONE to skip service generation.
- Defaulted service_generator_type to NONE
- Added /protos/extest/unittest_generic_services.proto to test services
- Migrated unit tests to use the new generic services for testing
Diffstat (limited to 'src/ProtocolBuffers.Test/ServiceTest.cs')
-rw-r--r-- | src/ProtocolBuffers.Test/ServiceTest.cs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/ProtocolBuffers.Test/ServiceTest.cs b/src/ProtocolBuffers.Test/ServiceTest.cs index f6f7c747..579c4582 100644 --- a/src/ProtocolBuffers.Test/ServiceTest.cs +++ b/src/ProtocolBuffers.Test/ServiceTest.cs @@ -50,12 +50,12 @@ namespace Google.ProtocolBuffers { delegate void Action<T1, T2>(T1 t1, T2 t2); - private static readonly MethodDescriptor FooDescriptor = TestService.Descriptor.Methods[0]; - private static readonly MethodDescriptor BarDescriptor = TestService.Descriptor.Methods[1]; + private static readonly MethodDescriptor FooDescriptor = TestGenericService.Descriptor.Methods[0];
+ private static readonly MethodDescriptor BarDescriptor = TestGenericService.Descriptor.Methods[1]; [Test] public void GetRequestPrototype() { - TestService service = new TestServiceImpl(); + TestGenericService service = new TestServiceImpl(); Assert.AreSame(service.GetRequestPrototype(FooDescriptor), FooRequest.DefaultInstance); Assert.AreSame(service.GetRequestPrototype(BarDescriptor), BarRequest.DefaultInstance); @@ -63,7 +63,7 @@ namespace Google.ProtocolBuffers { [Test] public void GetResponsePrototype() { - TestService service = new TestServiceImpl(); + TestGenericService service = new TestServiceImpl(); Assert.AreSame(service.GetResponsePrototype(FooDescriptor), FooResponse.DefaultInstance); Assert.AreSame(service.GetResponsePrototype(BarDescriptor), BarResponse.DefaultInstance); @@ -71,14 +71,14 @@ namespace Google.ProtocolBuffers { [Test] public void CallMethodFoo() { - MockRepository mocks = new MockRepository(); - FooRequest fooRequest = FooRequest.CreateBuilder().Build(); + MockRepository mocks = new MockRepository();
+ FooRequest fooRequest = FooRequest.CreateBuilder().Build();
FooResponse fooResponse = FooResponse.CreateBuilder().Build(); IRpcController controller = mocks.StrictMock<IRpcController>(); bool fooCalled = false; - TestService service = new TestServiceImpl((request, responseAction) => { + TestGenericService service = new TestServiceImpl((request, responseAction) => { Assert.AreSame(fooRequest, request); fooCalled = true; responseAction(fooResponse); @@ -115,8 +115,8 @@ namespace Google.ProtocolBuffers { FooRequest fooRequest = FooRequest.CreateBuilder().Build(); MockRepository mocks = new MockRepository(); IRpcChannel mockChannel = mocks.StrictMock<IRpcChannel>(); - IRpcController mockController = mocks.StrictMock<IRpcController>(); - TestService service = TestService.CreateStub(mockChannel); + IRpcController mockController = mocks.StrictMock<IRpcController>();
+ TestGenericService service = TestGenericService.CreateStub(mockChannel);
Action<FooResponse> doneHandler = mocks.StrictMock<Action<FooResponse>>(); using (mocks.Record()) { @@ -126,7 +126,7 @@ namespace Google.ProtocolBuffers { .IgnoreArguments() .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))); + .Do((CallFooDelegate) ((p1, p2, p3, response, done) => done(response)));
doneHandler(FooResponse.DefaultInstance); } @@ -137,14 +137,14 @@ namespace Google.ProtocolBuffers { [Test] public void CallMethodBar() { - MockRepository mocks = new MockRepository(); - BarRequest barRequest = BarRequest.CreateBuilder().Build(); + MockRepository mocks = new MockRepository();
+ BarRequest barRequest = BarRequest.CreateBuilder().Build();
BarResponse barResponse = BarResponse.CreateBuilder().Build(); IRpcController controller = mocks.StrictMock<IRpcController>(); bool barCalled = false; - TestService service = new TestServiceImpl(null, (request, responseAction) => { + TestGenericService service = new TestServiceImpl(null, (request, responseAction) => { Assert.AreSame(barRequest, request); barCalled = true; responseAction(barResponse); @@ -168,15 +168,15 @@ namespace Google.ProtocolBuffers { } - class TestServiceImpl : TestService { + class TestServiceImpl : TestGenericService { private readonly Action<FooRequest, Action<FooResponse>> fooHandler; private readonly Action<BarRequest, Action<BarResponse>> barHandler; private readonly IRpcController expectedController; internal TestServiceImpl() { - } - - internal TestServiceImpl(Action<FooRequest, Action<FooResponse>> fooHandler, + }
+
+ internal TestServiceImpl(Action<FooRequest, Action<FooResponse>> fooHandler,
Action<BarRequest, Action<BarResponse>> barHandler, IRpcController expectedController) { this.fooHandler = fooHandler; |