public void TestReadWriteString03() { //Functionality test on ReadString(ulong expectedSignature, string defaultValue) and WriteString(ulong signature, string value) //Initial value expected since matched signature. // IStorage storage = new BinaryStorage(); ulong signature = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'S', 'T', 'R'); storage.WriteString(signature, "Hello World"); long position = storage.GetPosition(); Assert.AreEqual(20, position); storage.Seek(0, SeekOrigin.Begin); string returned = storage.ReadString(signature, "World Hello"); Assert.AreEqual("Hello World", returned); }
public void TestReadWriteString00() { //Functionality test on ReadString(ulong expectedSignature) and WriteDouble(ulong signature, string value) //Exception expected due to unmatched signature. // IStorage storage = new BinaryStorage(); ulong signature00 = Utilities.MakeEightCC('T', 'E', 'S', 'T', ' ', 'S', 'T', 'R'); ulong signature01 = Utilities.MakeEightCC('T', 'E', 'S', 'T', '_', 'S', 'T', 'R'); storage.WriteString(signature00, "Hello World"); long position = storage.GetPosition(); Assert.AreEqual(20, position); storage.Seek(0, SeekOrigin.Begin); Assert.Throws <InvalidDataException>(() => { string returned = storage.ReadString(signature01); }); }