Exemple #1
0
        public void TestManual()
        {
            SerializerTypes.AddType(
                new BinTypeDescription(typeof(Manual), "Manual")
                , new BinTypeVersion(10, 0)
                , BinTypeProcess.Create <Manual>(Manual.Write, Manual.Read)
                );

            var input = new Manual();

            input.FieldOne = "asd";
            input.FieldTwo = "lsd";

            var output = SerializeDeserialize(input);

            Assert.AreEqual(input.FieldOne, output.FieldOne);
            Assert.AreEqual(input.FieldTwo, output.FieldTwo);
        }
Exemple #2
0
        public void CallbacksManualTest()
        {
            SerializerTypes.AddType(
                new BinTypeDescription(typeof(CallbacksTestManualType), "CallbacksTestManualType")
                , new BinTypeVersion(42, 0)
                , BinTypeProcess.Create <CallbacksTestManualType>(CallbacksTestManualType.Write, CallbacksTestManualType.Read)
                );

            var instance = new CallbacksTestManualType();

            instance.First = 10;

            var result = SerializeDeserialize(instance);

            Assert.AreEqual(result.First, 10);
            Assert.AreEqual(result.Second, 10);
            Assert.AreEqual(result.FromFirstAndSecond, 100);
        }
Exemple #3
0
        public void TestManualGeneric()
        {
            var write = typeof(SerializeTests).GetMethod("WriteManualGeneric", BindingFlags.Static | BindingFlags.Public);
            var read  = typeof(SerializeTests).GetMethod("ReadManualGeneric", BindingFlags.Static | BindingFlags.Public);

            SerializerTypes.AddType(
                new BinTypeDescription(typeof(ManualGenericType <,>), "ManualGenericType")
                , new BinTypeVersion(10, 0)
                , BinTypeProcess.Create(write, read)
                );

            var input = new ManualGenericType <string, string>();

            input.FieldOne = "asd";
            input.FieldTwo = "lsd";

            var output = SerializeDeserialize(input);

            Assert.AreEqual(input.FieldOne, output.FieldOne);
            Assert.AreEqual(input.FieldTwo, output.FieldTwo);
        }