public void DecryptWholeFileTest(string inputFile, string expectedFile) { using (FileStream fileStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read)) { using SegsStream segsStream = new SegsStream(fileStream, SegsStreamMode.Decompress); using FileStream outStream = new FileStream("temp.dat", FileMode.Create, FileAccess.Write); segsStream.CopyTo(outStream); } bool eq = Compare.CompareFiles(expectedFile, "temp.dat"); File.Delete("temp.dat"); Assert.IsTrue(eq); }
public async Task CompressUncompressTest(string inputFile) { using (FileStream fileStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read)) { using FileStream outStream = new FileStream("temp.dat", FileMode.Create, FileAccess.Write); await SegsStream.CompressStream(fileStream, outStream); } using (FileStream compStream = new FileStream("temp.dat", FileMode.Open, FileAccess.Read)) { using SegsStream segsStream = new SegsStream(compStream, SegsStreamMode.Decompress); using FileStream outStream = new FileStream("temp2.dat", FileMode.Create, FileAccess.Write); segsStream.CopyTo(outStream); } bool eq = Compare.CompareFiles(inputFile, "temp2.dat"); File.Delete("temp.dat"); File.Delete("temp2.dat"); Assert.IsTrue(eq); }
public void DecryptSeekTest(string inputFile, string expectedFile, int offset) { using (FileStream fileStream = new FileStream(inputFile, FileMode.Open, FileAccess.Read)) { using SegsStream segsStream = new SegsStream(fileStream, SegsStreamMode.Decompress); using FileStream outStream = new FileStream("temp.dat", FileMode.Create, FileAccess.Write); segsStream.Seek(offset, SeekOrigin.Begin); segsStream.CopyTo(outStream); } using (FileStream fileStream1 = new FileStream(expectedFile, FileMode.Open, FileAccess.Read)) { using FileStream outStream = new FileStream("temp_exp.dat", FileMode.Create, FileAccess.Write); fileStream1.Seek(offset, SeekOrigin.Begin); fileStream1.CopyTo(outStream); } bool eq = Compare.CompareFiles("temp_exp.dat", "temp.dat"); File.Delete("temp.dat"); File.Delete("temp_exp.dat"); Assert.IsTrue(eq); }