private static Table LoadTable(string tableName) { Table table = new Table(); Trace.Write(String.Format("Loading Table '{0}'...\r\n", tableName)); Trace.Write(String.Format("\tDisk Size: {0}\r\n", BinarySerializable.Size(String.Format(@"Tables\{0}", tableName)).SizeString())); Trace.Write(String.Format("\tMemory Use: {0}\r\n", Memory.MeasureObjectSize(() => { table.Load(tableName); return(table); }).SizeString())); return(table); }
public void BinarySerializable_BasicRoundTrip() { SampleSerializable sample = new SampleSerializable(12345); sample.Write("Sample"); SampleSerializable sampleRead = new SampleSerializable(0); Assert.IsTrue(sampleRead.TryRead("Sample")); Assert.AreEqual(4, BinarySerializable.Size("Sample")); Assert.AreEqual(sample.Value, sampleRead.Value); }
public void BinarySerializable_EnumerateAndDelete() { IEnumerable <string> items; // Delete any pre-existing items foreach (string serializedItem in BinarySerializable.EnumerateUnder(".")) { BinarySerializable.Delete(serializedItem); } // Add one item SampleSerializable sample = new SampleSerializable(12345); sample.Write("Sample"); // Verify folder size finds one item only Assert.AreEqual(4, BinarySerializable.Size(".")); // Verify it is found items = BinarySerializable.EnumerateUnder("."); Assert.AreEqual(1, items.Count()); // Add another item sample.Write("Sample2"); // Verify both are found items = BinarySerializable.EnumerateUnder("."); Assert.AreEqual(2, items.Count()); // Verify folder size finds both items Assert.AreEqual(8, BinarySerializable.Size(".")); // Delete first item; verify count drops BinarySerializable.Delete("Sample"); items = BinarySerializable.EnumerateUnder("."); Assert.AreEqual(1, items.Count()); }