public void BinarySerializable_WrongTypeRead()
        {
            SampleSerializable sample = new SampleSerializable(12345);

            sample.Write("Sample");

            SampleSerializable2 wrongType = new SampleSerializable2(0);

            Assert.IsFalse(wrongType.TryRead("Sample"));
        }
        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());
        }