public void SerializationOfMixinBaseWorks() { BaseType3 bt3 = CreateMixedObject <BaseType3> (typeof(BT3Mixin1), typeof(BT3Mixin1B)); var mixin = Mixin.Get <BT3Mixin1> (bt3); Assert.That(mixin.Next, Is.Not.Null); Assert.That(mixin.Next.GetType(), Is.SameAs(bt3.GetType().GetField("__first", BindingFlags.NonPublic | BindingFlags.Instance).FieldType)); var mixin2 = Mixin.Get <BT3Mixin1B> (bt3); Assert.That(mixin2.Next, Is.Not.Null); Assert.That(mixin2.Next.GetType(), Is.SameAs(bt3.GetType().GetField("__first", BindingFlags.NonPublic | BindingFlags.Instance).FieldType)); BaseType3 bt3A = Serializer.SerializeAndDeserialize(bt3); var mixinA = Mixin.Get <BT3Mixin1> (bt3A); Assert.That(mixinA, Is.Not.SameAs(mixin)); Assert.That(mixinA.Next, Is.Not.Null); Assert.That(mixinA.Next.GetType(), Is.SameAs(bt3A.GetType().GetField("__first", BindingFlags.NonPublic | BindingFlags.Instance).FieldType)); var mixin2A = Mixin.Get <BT3Mixin1B> (bt3A); Assert.That(mixin2A, Is.Not.SameAs(mixin2)); Assert.That(mixin2A.Next, Is.Not.Null); Assert.That(mixin2A.Next.GetType(), Is.SameAs(bt3A.GetType().GetField("__first", BindingFlags.NonPublic | BindingFlags.Instance).FieldType)); }
public void InstantiatedSubclassProxyHasNextCallProxy() { BaseType3 bt3 = CreateMixedObject <BaseType3> (typeof(BT3Mixin3 <,>)); FieldInfo firstField = bt3.GetType().GetField("__first", BindingFlags.NonPublic | BindingFlags.Instance); Assert.That(firstField.GetValue(bt3), Is.Not.Null); }
public void GenericMixinsAreSpecialized() { BaseType3 bt3 = CreateMixedObject <BaseType3> (typeof(BT3Mixin3 <,>)); object mixin = Mixin.Get(typeof(BT3Mixin3 <,>), bt3); Assert.That(mixin, Is.Not.Null); PropertyInfo targetProperty = MixinReflector.GetTargetProperty(mixin.GetType()); Assert.That(targetProperty, Is.Not.Null); Assert.That(targetProperty.GetValue(mixin, null), Is.Not.Null); Assert.That(targetProperty.GetValue(mixin, null), Is.SameAs(bt3)); Assert.That(targetProperty.PropertyType, Is.EqualTo(typeof(BaseType3))); PropertyInfo nextProperty = MixinReflector.GetNextProperty(mixin.GetType()); Assert.That(nextProperty, Is.Not.Null); Assert.That(nextProperty.GetValue(mixin, null), Is.Not.Null); Assert.That(nextProperty.GetValue(mixin, null).GetType(), Is.SameAs(bt3.GetType().GetField("__first", BindingFlags.NonPublic | BindingFlags.Instance).FieldType)); Assert.That(nextProperty.PropertyType, Is.EqualTo(typeof(IBaseType33))); }