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 Execute(IPlatformFactory factory, ITestLogger logger) { ByteReaderTestData.Init(); var testString = ByteReaderTestData.testString; MgByteReader reader = new MgByteReader(testString, "text/html"); Assert.AreEqual(testString.Length, reader.GetLength()); string buf = reader.ToString(); Assert.AreEqual(testString, buf); Assert.AreEqual(testString.Length, reader.GetLength()); reader.Rewind(); Assert.AreEqual(testString.Length, reader.GetLength()); }
public void Execute(IPlatformFactory factory, ITestLogger logger) { string tmp = Path.GetTempFileName(); try { File.WriteAllText(tmp, "Hello World"); MgByteSource bs = new MgByteSource(tmp); MgByteReader reader = bs.GetReader(); MgGeometryProperty gp = new MgGeometryProperty("GeomPropName", reader); MgByteSource bs2 = new MgByteSource("../../TestData/DrawingService/SpaceShip.dwf"); MgByteReader reader2 = bs2.GetReader(); gp.Value = reader2; Assert.AreEqual(reader2.GetLength(), gp.Value.GetLength()); Assert.AreEqual(MgPropertyType.Geometry, gp.PropertyType); } finally { try { File.Delete(tmp); } catch { } } }
public ImageResponseDialog(MgByteReader reader) : this() { byte[] b = new byte[reader.GetLength()]; reader.Read(b, b.Length); using (var ms = new MemoryStream(b)) { var img = Image.FromStream(ms); picResult.Image = img; this.Width = img.Width; this.Height = img.Height; } }
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(); }
public void StringConstructor() { MgByteReader reader = new MgByteReader(testString, "text/html"); Assert.AreEqual(testString.Length, reader.GetLength()); string buf = reader.ToString(); Assert.AreEqual(testString, buf); Assert.AreEqual(testString.Length, reader.GetLength()); reader.Rewind(); Assert.AreEqual(testString.Length, reader.GetLength()); }