public void AppLogRecord_ReadWrite_Indexer() { EnhancedMemoryStream es = new EnhancedMemoryStream(); AppLogRecord r; for (int i = 0; i < 1000; i++) { byte[] arr; arr = new byte[i]; for (int j = 0; j < i; j++) { arr[j] = (byte)j; } r = new AppLogRecord(); r["index"] = i; r["bytes"] = arr; r["bool"] = true; r.Write(es); } es.Position = 0; for (int i = 0; i < 1000; i++) { byte[] arr; arr = new byte[i]; for (int j = 0; j < i; j++) { arr[j] = (byte)j; } r = new AppLogRecord(); r.Read(es); Assert.AreEqual(i.ToString(), (string)r["index"]); CollectionAssert.AreEqual(arr, (byte[])r["bytes"]); Assert.AreEqual("True", (string)r["bool"]); } Assert.IsTrue(es.Eof); }
public void AppLogRecord_ReadWrite_LargeString() { EnhancedMemoryStream es = new EnhancedMemoryStream(); AppLogRecord r; string s; s = new String('x', 1000000); r = new AppLogRecord(); r.Add("string", s); r.Write(es); es.Position = 0; r = new AppLogRecord(); r.Read(es); Assert.AreEqual(s, (string)r["string"]); }
public void AppLogRecord_ReadWrite_LargeByteArray() { EnhancedMemoryStream es = new EnhancedMemoryStream(); AppLogRecord r; byte[] arr; arr = new byte[1000000]; for (int j = 0; j < arr.Length; j++) { arr[j] = (byte)j; } r = new AppLogRecord(); r.Add("bytes", arr); r.Write(es); es.Position = 0; r = new AppLogRecord(); r.Read(es); CollectionAssert.AreEqual(arr, (byte[])r["bytes"]); }