コード例 #1
0
        public virtual void GetByIndexOutOfBoundsTest()
        {
            FileInfo file             = new FileInfo(SOURCE_FILE);
            int      indexOutOfBounds = content.Length;

            using (FileStream raf = FileUtil.GetRandomAccessFile(file)) {
                RAFRandomAccessSource source = new RAFRandomAccessSource(raf);
                NUnit.Framework.Assert.AreNotEqual(-1, source.Get(indexOutOfBounds - 1));
                NUnit.Framework.Assert.AreEqual(-1, source.Get(indexOutOfBounds));
            }
        }
コード例 #2
0
        public virtual void GetByIndexTest()
        {
            FileInfo file = new FileInfo(SOURCE_FILE);

            using (FileStream raf = FileUtil.GetRandomAccessFile(file)) {
                RAFRandomAccessSource source = new RAFRandomAccessSource(raf);
                for (int i = 0; i < content.Length; i++)
                {
                    NUnit.Framework.Assert.AreEqual(content[i], source.Get(i));
                }
            }
        }
コード例 #3
0
        public virtual void GetArrayByIndexesTest()
        {
            FileInfo file       = new FileInfo(SOURCE_FILE);
            int      beginIndex = 7;
            int      length     = 5;

            using (FileStream raf = FileUtil.GetRandomAccessFile(file)) {
                RAFRandomAccessSource source = new RAFRandomAccessSource(raf);
                byte[] dest = new byte[24];
                int    read = source.Get(beginIndex, dest, 0, length);
                NUnit.Framework.Assert.AreEqual(length, read);
                for (int i = 0; i < length; i++)
                {
                    NUnit.Framework.Assert.AreEqual(content[beginIndex + i], dest[i]);
                }
            }
        }