コード例 #1
0
ファイル: ByteReaderTest.cs プロジェクト: achilex/MgDev
        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();
        }
コード例 #2
0
 public override void Rewind()
 {
     if (!CanRewind)
     {
         throw new InvalidOperationException("This stream is not rewindable"); //LOCALIZEME
     }
     _reader.Rewind();
 }
コード例 #3
0
ファイル: MgReadOnlyStream.cs プロジェクト: achilex/MgDev
        /// <summary>
        /// Resets the internal position of the stream
        /// </summary>
        public override void Rewind()
        {
            if (!CanRewind)
            {
                throw new InvalidOperationException(Strings.ErrorStreamNotRewindable);
            }

            _reader.Rewind();
        }
コード例 #4
0
        /// <summary>
        /// Resets the internal position of the stream
        /// </summary>
        public override void Rewind()
        {
            if (!CanRewind)
            {
                throw new InvalidOperationException("Stream is not rewindable");
            }

            _reader.Rewind();
        }
コード例 #5
0
ファイル: ByteReaderTest.cs プロジェクト: achilex/MgDev
        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());
        }
コード例 #6
0
ファイル: ByteReaderTest.cs プロジェクト: kanbang/Colt
        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();
        }
コード例 #7
0
ファイル: ByteReaderTest.cs プロジェクト: achilex/MgDev
        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();
        }
コード例 #8
0
ファイル: ByteReaderTest.cs プロジェクト: kanbang/Colt
 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());
 }
コード例 #9
0
ファイル: ByteReaderTest.cs プロジェクト: kanbang/Colt
        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();
        }