My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#warning excised
//using System;
//using System.Linq;
//using System.ServiceModel;
//using DAL;
//using NUnit.Framework;
//using ProtoBuf;
//using ProtoBuf.ServiceModel.Client;
//using ProtoBuf.ServiceModel.Server;

//namespace Examples.Rpc
//{
// [ProtoContract]
// class TestRequest {
// [ProtoMember(1)] public int RequestBody { get; set; }
// }
// [ProtoContract] class TestResponse {
// [ProtoMember(1)] public int ResponseBody { get; set; }
// }
// interface IBasicService
// {
// [OperationContract(Action="Foo")]
// DAL.Database TestMethod(DAL.Database request);

// void Ping();

// int Test(int inOnly, ref int inOut, out int outOnly);
// }
// class BasicService : IBasicService
// {
// public DAL.Database TestMethod(DAL.Database request)
// {
// return request;
// }
// public void Ping() { }

// public int Test(int inOnly, ref int inOut, out int outOnly)
// {
// outOnly = inOut;
// inOut = inOnly;
// return outOnly + inOut;
// }
// }

// class BasicServiceHttpClient : ProtoClient<IBasicService>, IBasicService
// {
// public BasicServiceHttpClient() : base(HttpBasic.ViaHttp()) { }
// public void Ping() { }
// public void TestMethod(DAL.Database request, Action<DAL.Database> callback)
// {
// InvokeAsync("TestMethod", delegate(AsyncResult result) { callback((DAL.Database)result()); }, request);
// }
// public DAL.Database TestMethod(DAL.Database request)
// {
// return (DAL.Database) Invoke("TestMethod", request);
// }
// public int Test(int inOnly, ref int inOut, out int outOnly)
// {
// outOnly = inOut;
// inOut = inOnly;
// return outOnly + inOut;
// }
// }

// [TestFixture]
// public class HttpWithLambda
// {
// private HttpServer server;
// [SetUp]
// public void StartServer()
// {
// StopServer();
// server = new HttpServer(HTTP_PREFIX);
// server.Add<IBasicService>(new BasicService());
// server.Start();
// }

// [TearDown]
// public void StopServer()
// {
// if (server != null)
// {
// try { server.Close(); }
// catch { }
// server = null;
// }
// }


// [Test]
// public void TestPing() {
// using (var client = CreateClient())
// {
// client.Invoke(svc => svc.Ping());
// }
// }

// [Test]
// public void TestSwapArgs()
// {
// using (var client = CreateClient())
// {
// int i = 13, j = 0;
// int sum = client.Invoke(svc => svc.Test(27, ref i, out j));
// Assert.AreEqual(27, i);
// Assert.AreEqual(13, j);
// Assert.AreEqual(40, sum);
// }
// }

// const string HTTP_PREFIX = "http://localhost:8080/myapp/";
// static ProtoClient<IBasicService> CreateClient()
// {
// return new ProtoClient<IBasicService>(new HttpBasicTransport(HTTP_PREFIX));
// }
// }

// [TestFixture]
// public class HttpBasic
// {
// const string HTTP_PREFIX = "http://localhost:8080/myapp/";
// internal static ITransport ViaHttp() {
// return new HttpBasicTransport(HTTP_PREFIX);
// }
// static ProtoClient<T> ClientViaHttp<T>() where T : class {
// return new ProtoClient<T>(
// ViaHttp());
// }

// [Test, ExpectedException(typeof(ArgumentNullException))]
// public void TestNullTransport()
// {
// new ProtoClient<IBasicService>(null);
// }
// class NotAContract { }
// [Test, ExpectedException(typeof(ArgumentException))]
// public void TestNotAContract() {
// new ProtoClient<NotAContract>(ViaHttp());
// }

// [Test]
// public void TestCreationAndDispoesWithBoth() {
// using(ClientViaHttp<IBasicService>()) {}
// }

// [Test]
// public void TestCreateDisposeClient()
// {
// using (var client = new BasicServiceHttpClient()) { }
// }

// [Test]
// public void StartStopServer()
// {
// using (var server = CreateServer())
// {
// server.Start();
// server.Close();
// }
// }
// static HttpServer CreateServer() { return CreateServer(new BasicService()); }
// static HttpServer CreateServer(IBasicService service)
// {
// HttpServer server = new HttpServer(HTTP_PREFIX);
// server.Add<IBasicService>(service);
// return server;
// }

// [Test]
// public void TestCallTestMethodWithNull()
// {
// using (var server = CreateServer())
// using (var client = new BasicServiceHttpClient())
// {
// server.Start();
// var result = client.TestMethod(null);
// Assert.IsNull(result);
// }
// }

// [Test]
// public void TestCallTestMethodWithDatabase()
// {
// using (var server = CreateServer())
// using (var client = new BasicServiceHttpClient())
// {
// server.Start();
// DAL.Database request = NWindTests.LoadDatabaseFromFile<DAL.Database>();
// DAL.Database response = client.TestMethod(request);

// Assert.IsNotNull(response);
// Assert.AreNotSame(request, response);

// Assert.AreEqual(request.Orders.Count, response.Orders.Count, "Orders");
// Assert.AreEqual(
// request.Orders.SelectMany(ord => ord.Lines).Count(),
// response.Orders.SelectMany(ord => ord.Lines).Count(), "Lines");
// Assert.AreEqual(
// request.Orders.SelectMany(ord => ord.Lines).Sum(line => line.Quantity),
// response.Orders.SelectMany(ord => ord.Lines).Sum(line => line.Quantity), "Quantity");
// Assert.AreEqual(
// request.Orders.SelectMany(ord => ord.Lines).Sum(line => line.Quantity * line.UnitPrice),
// response.Orders.SelectMany(ord => ord.Lines).Sum(line => line.Quantity * line.UnitPrice), "Value");

// }
// }

// }
//}

Change log

r303 by marc.gravell on Mar 9, 2010   Diff
Fixed for non-trivial models (NWind); lots
of fixes; v1 test rig now tied in.
Go to: 
Project members, sign in to write a code review

Older revisions

r245 by marc.gravell on Mar 26, 2009   Diff
Multiple services on http endpoint;
bundle extensions into Silverlight
csproj
r244 by marc.gravell on Mar 25, 2009   Diff
RPC; first draft. Still very much a
work in progress, and the binary
format is expected to change when the
CF/generic refactoring is complete.
r242 by marc.gravell on Mar 13, 2009   Diff
Client/Server RPC take 2
All revisions of this file

File info

Size: 6918 bytes, 209 lines
Powered by Google Project Hosting