protected override void HandleResponse(TransferFileBytesRequest message,
                                        IChannelHandlerContext channelHandlerContext,
                                        PeerId senderPeerIdentifier,
                                        ICorrelationId correlationId)
 {
     _fileTransferFactory.DownloadChunk(message);
 }
        public void CanHandlerDownloadChunk()
        {
            var guid    = CorrelationId.GenerateCorrelationId();
            var request = new TransferFileBytesRequest
            {
                ChunkBytes          = ByteString.Empty,
                ChunkId             = 1,
                CorrelationFileName = CorrelationId.GenerateCorrelationId().Id.ToByteString()
            }.ToProtocolMessage(PeerIdHelper.GetPeerId("Test"), guid);

            _downloadFileTransferFactory.DownloadChunk(Arg.Any <TransferFileBytesRequest>())
            .Returns(FileTransferResponseCodeTypes.Successful);

            request.SendToHandler(_context, _observer);
            _downloadFileTransferFactory.Received(1).DownloadChunk(Arg.Any <TransferFileBytesRequest>());
        }
        public void Can_Download_Chunk()
        {
            SetupDownload(CancellationToken.None);
            var correlationId = _downloadFileInformation.CorrelationId;

            _downloadFileTransferFactory.DownloadChunk(new TransferFileBytesRequest
            {
                ChunkBytes          = new byte[1].ToByteString(),
                ChunkId             = 1,
                CorrelationFileName = correlationId.Id.ToByteString()
            }).Should().Be(FileTransferResponseCodeTypes.Successful);

            _downloadFileInformation.ReceivedWithAnyArgs().WriteToStream(default, default);
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="transferFileBytesRequest"></param>
        /// <param name="channelHandlerContext"></param>
        /// <param name="senderPeerId"></param>
        /// <param name="correlationId"></param>
        /// <returns></returns>
        protected override TransferFileBytesResponse HandleRequest(TransferFileBytesRequest transferFileBytesRequest,
                                                                   IChannelHandlerContext channelHandlerContext,
                                                                   PeerId senderPeerId,
                                                                   ICorrelationId correlationId)
        {
            Guard.Argument(transferFileBytesRequest, nameof(transferFileBytesRequest)).NotNull();
            Guard.Argument(channelHandlerContext, nameof(channelHandlerContext)).NotNull();
            Guard.Argument(senderPeerId, nameof(senderPeerId)).NotNull();
            Logger.Debug("received message of type TransferFileBytesRequest");

            FileTransferResponseCodeTypes responseCodeType = _fileTransferFactory.DownloadChunk(transferFileBytesRequest);

            return(new TransferFileBytesResponse
            {
                ResponseCode = ByteString.CopyFrom((byte)responseCodeType.Id)
            });
        }