public void SendBinaryFileTest() { // Create a temporary text file as the file to send testFileName = CreateTestBinaryFile(); // Create a CvsStream based on a MemoryStream for SendTextFile to send the file to MemoryStream memoryStream = new MemoryStream(); CvsStream cvsStream = new CvsStream(memoryStream); // Call the function under test UncompressedFileHandler fileHandler = new UncompressedFileHandler(); fileHandler.SendBinaryFile(cvsStream, testFileName); // check what SendBinaryFile put in the stream CheckBinaryStream(cvsStream, false); }
public void ReceiveBinaryFileTest() { // Create a CvsStream based on a MemoryStream for ReceiveTextFile to receive the file from MemoryStream memoryStream = new MemoryStream(); CvsStream cvsStream = new CvsStream(memoryStream); CreateBinaryStream(cvsStream); cvsStream.Position = 0; // Create a temporary file to receive the file to testFileName = Path.GetTempFileName(); // Call the function under test UncompressedFileHandler fileHandler = new UncompressedFileHandler(); fileHandler.ReceiveBinaryFile(cvsStream, testFileName, GetBinaryLen(BINARY_BLOCKS)); // Now validate that the file we received is as expected CheckBinaryFile(testFileName); }
public void ReceiveTextFileTest() { int linefeedChars = 1; // we emulate input from cvs so only 1 linefeed char // Create a CvsStream based on a MemoryStream for ReceiveTextFile to receive the file from MemoryStream memoryStream = new MemoryStream(); CvsStream cvsStream = new CvsStream(memoryStream); // put a text file into the stream CreateTextStream(cvsStream); cvsStream.Position = 0; // Create a temporary file to receive the file to testFileName = Path.GetTempFileName(); // Call the function under test UncompressedFileHandler fileHandler = new UncompressedFileHandler(); fileHandler.ReceiveTextFile(cvsStream, testFileName, GetTextLen(TEXT_BLOCKS, linefeedChars)); // check the received file CheckTextFile(testFileName); }