public void Writing_Whole_File_In_Streamed_Blocks_Should_Create_Exact_Copy()
        {
            //use an output stream which works with buffers
            StreamedBlockOutputStream os = new StreamedBlockOutputStream(Token, 15000, b => UploadHandler.WriteBlockStreamed(b));
            MemoryStream ms = new MemoryStream(SourceFileContents);

            ms.WriteTo(os);

            UploadHandler.CompleteTransfer(Token.TransferId);

            TargetFile.Refresh();
            FileAssert.AreEqual(SourceFilePath, TargetFilePath);


            TargetFile.Delete();
            InitToken();

            //use a source strem
            using (var fs = SourceFile.OpenRead())
            {
                fs.WriteTo(Token, SourceFile.Length, 10000, b => UploadHandler.WriteBlockStreamed(b));
                UploadHandler.CompleteTransfer(Token.TransferId);

                TargetFile.Refresh();
                FileAssert.AreEqual(SourceFilePath, TargetFilePath);
            }
        }
Esempio n. 2
0
        public void Writing_Whole_File_In_Streamed_Blocks_Should_Create_Exact_Copy()
        {
            //use an output stream which works with streams
            StreamedBlockOutputStream os = new StreamedBlockOutputStream(Token, 2048, b => Uploads.WriteBlockStreamed(b));

            using (var fs = SourceFile.OpenRead())
            {
                fs.WriteTo(os);
            }

            Uploads.CompleteTransfer(Token.TransferId);
            CompareUploadToSourceFile();


            //delete file
            FileSystem.DeleteFile(TargetFilePath);
            InitToken();

            //use a source strem
            using (var fs = SourceFile.OpenRead())
            {
                fs.WriteTo(Token, SourceFile.Length, 2048, b => Uploads.WriteBlockStreamed(b));
            }

            Uploads.CompleteTransfer(Token.TransferId);
            CompareUploadToSourceFile();
        }