Exemple #1
0
        public void CallServer_And_Receive_Call_Result_ViaRpcServer()
        {
            MockListener <JToken> mockListener = new MockListener <JToken>();

            var wampRpcServiceHost = new WampRpcMetadataCatalog();

            wampRpcServiceHost.Register(new MethodInfoWampRpcMetadata(new AddCalculator()));

            WampRpcServer <JToken> rpcServer =
                new WampRpcServer <JToken>(mFormatter,
                                           wampRpcServiceHost);

            WampListener <JToken> listener = GetListener(mockListener, rpcServer);

            MockConnection <JToken> connection = new MockConnection <JToken>(mFormatter);

            WampRpcClientFactory <JToken> factory =
                new WampRpcClientFactory <JToken>(new WampRpcSerializer(new WampDelegateProcUriMapper(x => "http://www.yogev.com/pr/" + x.Name)),
                                                  new WampRpcClientHandlerBuilder <JToken>(mFormatter,
                                                                                           new WampServerProxyFactory <JToken>(new WampServerProxyBuilder <JToken, IWampRpcClient <JToken>, IWampServer>(new WampOutgoingRequestSerializer <JToken>(mFormatter),
                                                                                                                                                                                                         new WampServerProxyOutgoingMessageHandlerBuilder <JToken, IWampRpcClient <JToken> >(new WampServerProxyIncomingMessageHandlerBuilder <JToken, IWampRpcClient <JToken> >(mFormatter))))));

            listener.Start();

            IAddCalculator calculator = factory.GetClient <IAddCalculator>(connection.SideAToSideB);

            mockListener.OnNext(connection.SideBToSideA);

            int sixteen = calculator.Add(10, 6);

            Assert.That(sixteen, Is.EqualTo(16));
        }
 /// <summary>Initializes a new instance of the <see cref="ScoreCalculator" /> class.</summary>
 /// <param name="shred30Contacts">The shred30 contacts.</param>
 /// <param name="contactArrangers">The contact arrangers.</param>
 /// <param name="validators">The validators.</param>
 /// <param name="addCalculator">The add calculator.</param>
 public StandardShred30ScoreCalculator(IEnumerable <IShred30Contact> shred30Contacts, IEnumerable <IShred30ContactArranger> contactArrangers, IEnumerable <IShredContact30Validator> validators, IAddCalculator addCalculator, IUniqueCalculator uniqueCalculator)
 {
     this.Shred30Contacts  = shred30Contacts;
     this.ContactArrangers = contactArrangers;
     this.Validators       = validators;
     this.AddCalculator    = addCalculator;
     this.UniqueCalculator = uniqueCalculator;
 }