private MemoryStream GetFakeDfsStream(FileTransferResponseCodeTypes fakeResponse)
        {
            var fakeStream = new MemoryStream();

            fakeStream.Write(new byte[50]);
            _dfs.ReadAsync(Arg.Any <Cid>()).Returns(fakeStream);
            _fileTransferFactory.RegisterTransfer(Arg.Any <IUploadFileInformation>()).Returns(fakeResponse);
            return(fakeStream);
        }
Пример #2
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)
            });
        }