public async Task Subscribe_To_Message_Stream_Should_Return_VersionRequest() { await _rpcServer.StartAsync(); VersionRequest returnedVersionRequest = null; var targetVersionRequest = new VersionRequest { Query = true }; var protocolMessage = targetVersionRequest.ToProtocolMessage(_peerId, CorrelationId.GenerateCorrelationId()); var observerDto = new ObserverDto(_channelHandlerContext, protocolMessage); _rpcServer.MessageStream .Where(x => x.Payload != null && x.Payload.TypeUrl == typeof(VersionRequest).ShortenedProtoFullName()) .SubscribeOn(_testScheduler) .Subscribe(request => returnedVersionRequest = request.Payload.FromProtocolMessage <VersionRequest>()); _mockSocketReplySubject.OnNext(observerDto); _testScheduler.Start(); targetVersionRequest.Should().Be(returnedVersionRequest); }
public void Valid_GetVersion_Request_Should_Send_VersionResponse() { var testScheduler = new TestScheduler(); var versionRequest = new VersionRequest(); var protocolMessage = versionRequest.ToProtocolMessage(PeerIdHelper.GetPeerId("sender")); var messageStream = MessageStreamHelper.CreateStreamWithMessage(_fakeContext, testScheduler, protocolMessage ); var peerSettings = PeerIdHelper.GetPeerId("sender").ToSubstitutedPeerSettings(); var handler = new GetVersionRequestObserver(peerSettings, _logger); handler.StartObserving(messageStream); testScheduler.Start(); var receivedCalls = _fakeContext.Channel.ReceivedCalls().ToList(); receivedCalls.Count.Should().Be(1); var sentResponseDto = (IMessageDto <ProtocolMessage>)receivedCalls.Single().GetArguments().Single(); var versionResponseMessage = sentResponseDto.Content.FromProtocolMessage <VersionResponse>(); versionResponseMessage.Version.Should().Be(NodeUtil.GetVersion()); }