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()); }
/// <summary> /// /// </summary> /// <param name="versionRequest"></param> /// <param name="channelHandlerContext"></param> /// <param name="senderPeerId"></param> /// <param name="correlationId"></param> /// <returns></returns> protected override VersionResponse HandleRequest(VersionRequest versionRequest, IChannelHandlerContext channelHandlerContext, PeerId senderPeerId, ICorrelationId correlationId) { Guard.Argument(versionRequest, nameof(versionRequest)).NotNull(); Guard.Argument(channelHandlerContext, nameof(channelHandlerContext)).NotNull(); Guard.Argument(senderPeerId, nameof(senderPeerId)).NotNull(); Logger.Debug("received message of type VersionRequest"); return(new VersionResponse { Version = NodeUtil.GetVersion() }); }