1+ using System . Reactive . Concurrency ;
2+ using System . Threading . Tasks ;
3+ using NUnit . Framework ;
4+ using WampSharp . Binding ;
5+ using WampSharp . V2 ;
6+ using WampSharp . V2 . Client ;
7+ using WampSharp . V2 . Core . Contracts ;
8+ using WampSharp . V2 . Rpc ;
9+ using WampSharp . V2 . Transports ;
10+
11+ namespace WampSharp . Tests . Wampv2 . Integration
12+ {
13+ public class GoodbyeTests
14+ {
15+ [ Test ]
16+ public async Task InMemoryTest ( )
17+ {
18+ var transport = new InMemoryTransport ( Scheduler . Default ) ;
19+ var binding = new JTokenJsonBinding ( ) ;
20+ var realm = "some.realm" ;
21+
22+ var router = new WampHost ( ) ;
23+ router . RegisterTransport ( transport , new [ ] { binding } ) ;
24+ router . Open ( ) ;
25+
26+ var calleeConnection = transport . CreateClientConnection ( binding , Scheduler . Default ) ;
27+ WampChannelFactory factory = new WampChannelFactory ( ) ;
28+
29+ var callee = factory . CreateChannel ( realm , calleeConnection , binding ) ;
30+ await callee . Open ( ) ;
31+ await callee . RealmProxy . Services . RegisterCallee ( new WampTest ( ) ) ;
32+
33+
34+ var callerConnection = transport . CreateClientConnection ( binding , Scheduler . Default ) ;
35+ var caller = factory . CreateChannel ( realm , callerConnection , binding ) ;
36+ await caller . Open ( ) ;
37+
38+ var proxy = caller . RealmProxy . Services . GetCalleeProxy < IWampTest > ( ) ;
39+ var result = await proxy . Echo ( "1" ) ;
40+ Assert . That ( result , Is . EqualTo ( "1" ) ) ;
41+
42+ await caller . Close ( WampErrors . CloseNormal , new GoodbyeDetails ( ) ) ;
43+ await callee . Close ( WampErrors . CloseNormal , new GoodbyeDetails ( ) ) ;
44+
45+ router . Dispose ( ) ;
46+ }
47+
48+ public interface IWampTest
49+ {
50+ [ WampProcedure ( "com.test.echo" ) ]
51+ Task < string > Echo ( string message ) ;
52+ }
53+
54+ public class WampTest : IWampTest
55+ {
56+ public Task < string > Echo ( string message )
57+ {
58+ return Task . FromResult ( message ) ;
59+ }
60+ }
61+
62+ }
63+ }
0 commit comments