public void TestReadWriteInteger03() { //Functionality test on ReadInteger(ulong expectedSignature, int defaultValue) and WriteInteger(ulong signature, int value) //Initial value expected since matched signature. // IStorage storage = new BinaryStorage(); ulong signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'I', 'N', 'T'); storage.WriteInteger(signature, 12); long position = storage.GetPosition(); Assert.AreEqual(12, position); storage.Seek(0, SeekOrigin.Begin); int returned = storage.ReadInteger(signature, 21); Assert.AreEqual(12, returned); }
public void TestGetPosition01() { //Assert MemoryStream cursor position before/after read operation. //MemoryStream needs to be written before reading, hence the involvement of write operation in this test. // IStorage storage = new BinaryStorage(); long beforeRead = storage.GetPosition(); Assert.AreEqual(0, beforeRead); ulong signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'I', 'N', 'T'); storage.WriteInteger(signature, 12); storage.Seek(-12, SeekOrigin.End); storage.ReadInteger(signature); long afterRead = storage.GetPosition(); Assert.AreEqual(12, afterRead); }
public void TestReadWriteInteger00() { //Functionality test on ReadInteger(ulong expectedSignature) and WriteInteger(ulong signature, int value) //Exception expected due to unmatched signature. // IStorage storage = new BinaryStorage(); ulong signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'I', 'N', 'T'); ulong signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', 'I', 'N', 'T'); storage.WriteInteger(signature00, 12); long position = storage.GetPosition(); Assert.AreEqual(12, position); storage.Seek(0, SeekOrigin.Begin); Assert.Throws <InvalidDataException>(() => { int returned = storage.ReadInteger(signature01); }); }