public void GetFileRequestHandlerInitializesFileUpload()
 {
     using (GetFakeDfsStream(FileTransferResponseCodeTypes.Successful))
     {
         _observer.OnNext(GetFileFromDfsRequestMessage());
         _dfs.Received(1).ReadAsync(Arg.Any <Cid>());
         _fileTransferFactory.Received(1)
         .FileTransferAsync(Arg.Any <ICorrelationId>(), Arg.Any <CancellationToken>());
     }
 }
        public void HandlerRemovesFileTransferOnError()
        {
            var channelHandlerContext = Substitute.For <IChannelHandlerContext>();
            var senderPeerIdentifier  = PeerIdHelper.GetPeerId();
            var correlationId         = CorrelationId.GenerateCorrelationId();

            var addFileResponse = new AddFileToDfsResponse
            {
                DfsHash      = "Test",
                ResponseCode = ByteString.CopyFrom((byte)FileTransferResponseCodeTypes.Error)
            };

            var addFileToDfsResponseObserver = new AddFileToDfsResponseObserver(
                Substitute.For <ILogger>(),
                _uploadFileTransferFactory
                );

            addFileToDfsResponseObserver.HandleResponseObserver(addFileResponse, channelHandlerContext,
                                                                senderPeerIdentifier, correlationId);
            _uploadFileTransferFactory.Received(1).Remove(Arg.Any <IUploadFileInformation>(), true);
        }