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)); } }
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)); } } }
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]); } } }