Ejemplo n.º 1
0
        public void SupportSettingCustomFactory_Clone()
        {
            var y = new YDerived();
            y.Z = CustomBonded<Z>.From(new Z { Value = 42 });
            var x = new X();
            x.bonded_Y = CustomBonded<Y>.From(y);

            var x1 = CustomTransformFactory.Instance.Cloner<X, X>().Clone<X>(x);

            Assert.That(x1, Is.Not.Null);
            Assert.That(x1.bonded_Y.Value.FullName, Is.EqualTo("CustomBondedTests.YDerived"));
            Assert.That(x1.bonded_Y.Convert<YDerived>().Value.Z.Value.Value, Is.EqualTo(42));
        }
Ejemplo n.º 2
0
        public void SupportSettingCustomFactory_RoundTrip()
        {
            var y = new YDerived();
            y.Z = CustomBonded<Z>.From(new Z {Value = 42});
            var x = new X();
            x.bonded_Y = CustomBonded<Y>.From(y);

            var buffer = new OutputBuffer();
            var writer = new CompactBinaryWriter<OutputBuffer>(buffer);
            CustomTransformFactory.Instance.Serializer<CompactBinaryWriter<OutputBuffer>, X>().Serialize(x, writer);

            var inputStream = new InputBuffer(buffer.Data);
            var reader = new CompactBinaryReader<InputBuffer>(inputStream);
            var x1 = CustomTransformFactory.Instance.Deserializer<CompactBinaryReader<InputBuffer>, X>(RuntimeSchema.Empty).Deserialize<X>(reader);

            Assert.That(x1, Is.Not.Null);
            Assert.That(x1.bonded_Y, Is.InstanceOf<CustomBonded<Y, CompactBinaryReader<InputBuffer>>>());
            Assert.That(x1.bonded_Y.Value.FullName, Is.EqualTo("CustomBondedTests.YDerived"));
            Assert.That(x1.bonded_Y.Convert<YDerived>().Value.Z.Value.Value, Is.EqualTo(42));

        }
Ejemplo n.º 3
0
 protected YDerived(string fullName, string name)
     : base(fullName, name)
 {
     Z = CustomBonded <Z> .From(Bond.GenericFactory.Create <Z>());
 }