Ejemplo n.º 1
0
        public void testSetPositionPastStream()
        {
            IndexedNumsStream ins = new IndexedNumsStream(10);

            ins.Seek(999, System.IO.SeekOrigin.End);
            Assert.AreEqual(ins.Position, ins.Length);
        }
Ejemplo n.º 2
0
        public void testStreamLeftToRead()
        {
            IndexedNumsStream ins = new IndexedNumsStream(7);

            byte[] buffer = new byte[100];

            ins.Seek(4, System.IO.SeekOrigin.Begin);
            int nBytes = ins.Read(buffer, 0, 7);

            Assert.AreEqual(3, nBytes);
        }
Ejemplo n.º 3
0
        public void testEndOfStream()
        {
            IndexedNumsStream ins = new IndexedNumsStream(600);

            byte[] buffer = new byte[100];

            ins.Seek(0, System.IO.SeekOrigin.End);
            int actual = ins.Read(buffer, 10, 10);

            Assert.AreEqual(0, actual);
        }
Ejemplo n.º 4
0
        public void testSeekBegin()
        {
            IndexedNumsStream ins = new IndexedNumsStream(600);

            System.IO.SeekOrigin origin = System.IO.SeekOrigin.Begin;

            //1)
            long newPosition = ins.Seek(999, origin);

            Assert.AreEqual(newPosition, 600);


            //2)
            newPosition = ins.Seek(-9999, origin);
            Assert.AreEqual(0, newPosition);

            //3)
            //position should now be at 0.
            newPosition = ins.Seek(50, origin);
            Assert.AreEqual(50, newPosition);
        }