public void Execute(IPlatformFactory factory, ITestLogger logger) { ByteReaderTestData.Init(); var nBytes = ByteReaderTestData.nBytes; var nBlocks = ByteReaderTestData.nBlocks; var testBytes = ByteReaderTestData.testBytes; var infileName = ByteReaderTestData.infileName; var outfileName = ByteReaderTestData.outfileName; byte[] buf = new byte[nBytes]; MgByteReader reader = new MgByteReader(infileName, "png", false); Assert.AreEqual(nBlocks * nBytes, reader.GetLength()); reader.Read(buf, nBytes); Assert.AreEqual(buf, testBytes); Assert.AreEqual((nBlocks - 1) * nBytes, reader.GetLength()); reader.Rewind(); Assert.AreEqual(nBlocks * nBytes, reader.GetLength()); reader.ToFile(outfileName); reader.Rewind(); byte[] buf2 = new byte[nBytes]; System.IO.FileStream fp = System.IO.File.OpenRead(outfileName); for (int j = 0; j < nBlocks; j++) { fp.Read(buf2, 0, nBytes); reader.Read(buf, nBytes); Assert.AreEqual(buf, buf2); } fp.Close(); }
public void FileConstructor() { byte[] buf = new byte[nBytes]; MgByteReader reader = new MgByteReader(infileName, "png", false); Assert.AreEqual(nBlocks * nBytes, reader.GetLength()); reader.Read(buf, nBytes); Assert.AreEqual(buf, testBytes); Assert.AreEqual((nBlocks-1) * nBytes, reader.GetLength()); reader.Rewind(); Assert.AreEqual(nBlocks * nBytes, reader.GetLength()); reader.ToFile(outfileName); reader.Rewind(); byte[] buf2 = new byte[nBytes]; System.IO.FileStream fp = System.IO.File.OpenRead(outfileName); for (int j = 0; j < nBlocks; j++) { fp.Read(buf2, 0, nBytes); reader.Read(buf, nBytes); Assert.AreEqual(buf, buf2); } fp.Close(); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { ByteReaderTestData.Init(); var nBytes = ByteReaderTestData.nBytes; var testBytes = ByteReaderTestData.testBytes; var outfileName = ByteReaderTestData.outfileName; byte[] buf = new byte[nBytes]; MgByteReader reader = new MgByteReader(testBytes, nBytes, "png"); Assert.AreEqual(nBytes, reader.GetLength()); reader.Read(buf, nBytes); Assert.AreEqual(buf, testBytes); Assert.AreEqual(0, reader.GetLength()); reader.Rewind(); Assert.AreEqual(nBytes, reader.GetLength()); reader.ToFile(outfileName); System.IO.FileStream fp = System.IO.File.OpenRead(outfileName); fp.Read(buf, 0, nBytes); Assert.AreEqual(buf, testBytes); fp.Close(); }
public void MemoryConstructor() { byte[] buf = new byte[nBytes]; MgByteReader reader = new MgByteReader(testBytes, nBytes, "png"); Assert.AreEqual(nBytes, reader.GetLength()); reader.Read(buf, nBytes); Assert.AreEqual(buf, testBytes); Assert.AreEqual(0, reader.GetLength()); reader.Rewind(); Assert.AreEqual(nBytes, reader.GetLength()); reader.ToFile(outfileName); System.IO.FileStream fp = System.IO.File.OpenRead(outfileName); fp.Read(buf, 0, nBytes); Assert.AreEqual(buf, testBytes); fp.Close(); }