Beispiel #1
0
        public static T GetRequest <T>(IRpcClient connected) where T : IMessage <T>
        {
            connected.Received(1).SendMessage(Arg.Any <IMessageDto <ProtocolMessage> >());

            var sentMessageDto = (IMessageDto <ProtocolMessage>)connected.ReceivedCalls()
                                 .Single(c => c.GetMethodInfo().Name == nameof(IRpcClient.SendMessage))
                                 .GetArguments()[0];

            return(sentMessageDto.Content.FromProtocolMessage <T>());
        }
Beispiel #2
0
        protected T AssertSentMessageAndGetMessageContent <T>() where T : IMessage <T>
        {
            RpcClient.Received(1).SendMessage(Arg.Is <IMessageDto <ProtocolMessage> >(x =>
                                                                                      x.Content != null &&
                                                                                      x.Content.GetType().IsAssignableTo <ProtocolMessage>() &&
                                                                                      x.Content.FromProtocolMessage <T>() != null
                                                                                      ));
            var sentMessageDto = (IMessageDto <ProtocolMessage>)RpcClient.ReceivedCalls()
                                 .Single(c => c.GetMethodInfo().Name == nameof(IRpcClient.SendMessage))
                                 .GetArguments()[0];
            var requestSent = sentMessageDto.Content.FromProtocolMessage <T>();

            return(requestSent);
        }