示例#1
0
        public void PersistentState_CanSerialize_Deserialize_ValueType()
        {
            TestValueType valueType = this.NewTestValueType();

            var serialized = this.serializer.Serialize(valueType);

            TestValueType deserialized = this.serializer.Deserialize <TestValueType>(serialized);

            TestValueTypeEqual(valueType, deserialized);
        }
示例#2
0
 private void TestValueTypeEqual(TestValueType type1, TestValueType type2)
 {
     Assert.Equal(type1.AddressField, type2.AddressField);
     Assert.Equal(type1.BoolField, type2.BoolField);
     Assert.Equal(type1.IntField, type2.IntField);
     Assert.Equal(type1.LongField, type2.LongField);
     Assert.Equal(type1.UintField, type2.UintField);
     Assert.Equal(type1.UlongField, type2.UlongField);
     Assert.Equal(type1.ByteField, type2.ByteField);
     Assert.Equal(type1.ByteArrayField, type2.ByteArrayField);
     Assert.Equal(type1.CharField, type2.CharField);
     Assert.Equal(type1.StringField, type2.StringField);
 }
示例#3
0
        private TestValueType NewTestValueType()
        {
            var instance = new TestValueType();

            instance.AddressField   = new uint160(123456).ToAddress();
            instance.BoolField      = true;
            instance.IntField       = 123;
            instance.LongField      = 123L;
            instance.UintField      = 123u;
            instance.UlongField     = 123ul;
            instance.ByteField      = 0x16;
            instance.ByteArrayField = new byte[] { 0x12, 0x24, 0x36, 0x48 };
            instance.CharField      = 'a';
            instance.StringField    = "Test123";

            return(instance);
        }
示例#4
0
        public void PersistentState_CanSerialize_Deserialize_NestedValueType()
        {
            TestValueType valueType = this.NewTestValueType();

            NestedValueType nestedValueType = new NestedValueType();

            nestedValueType.Id        = 123;
            nestedValueType.ValueType = valueType;

            var serialized = this.serializer.Serialize(nestedValueType);

            NestedValueType deserialized = this.serializer.Deserialize <NestedValueType>(serialized);

            TestValueType nested = deserialized.ValueType;

            Assert.Equal(nestedValueType.Id, deserialized.Id);
            TestValueTypeEqual(valueType, nested);
        }