public void CreateMixinWithMockedTarget_ThisBase()
        {
            var repository = new MockRepository();

            var thisMock = repository.StrictMock <IBaseType31> ();
            var baseMock = repository.StrictMock <IBaseType31> ();

            BT3Mixin1 mixin = MixinTargetMockUtility.CreateMixinWithMockedTarget <BT3Mixin1, IBaseType31, IBaseType31> (thisMock, baseMock);

            Assert.That(mixin.Target, Is.SameAs(thisMock));
            Assert.That(mixin.Next, Is.SameAs(baseMock));
        }
        public void CtorsRespectMixedTypeInstantiationScope()
        {
            Type generatedType         = TypeFactory.GetConcreteType(typeof(BaseType3));
            var  suppliedMixinInstance = new BT3Mixin1();

            using (new MixedObjectInstantiationScope(suppliedMixinInstance))
            {
                var bt3 = (BaseType3)Activator.CreateInstance(generatedType);
                Assert.That(Mixin.Get <BT3Mixin1> (bt3), Is.Not.Null);
                Assert.That(Mixin.Get <BT3Mixin1> (bt3), Is.SameAs(suppliedMixinInstance));
                Assert.That(suppliedMixinInstance.Target, Is.SameAs(bt3));
                Assert.That(Mixin.Get <BT3Mixin1> (bt3).Next, Is.Not.Null);
            }
        }
        public void Mock_ThisBaseConfig()
        {
            var repository = new MockRepository();

            var thisMock = repository.StrictMock <IBaseType31>();
            var baseMock = repository.StrictMock <IBaseType31>();

            var mixin = new BT3Mixin1();

            MixinTargetMockUtility.MockMixinTarget(mixin, thisMock, baseMock);

            Assert.That(mixin.Target, Is.SameAs(thisMock));
            Assert.That(mixin.Next, Is.SameAs(baseMock));
        }
        public void SignalOnDeserialized_ThisBase()
        {
            var thisMock = new SerializableBaseType31Mock();
            var baseMock = new SerializableBaseType31Mock();

            BT3Mixin1 mixin            = MixinTargetMockUtility.CreateMixinWithMockedTarget <BT3Mixin1, IBaseType31, IBaseType31> (thisMock, baseMock);
            var       deserializedData = Serializer.SerializeAndDeserialize(Tuple.Create(thisMock, baseMock, mixin));

            MixinTargetMockUtility.MockMixinTargetAfterDeserialization(deserializedData.Item3, deserializedData.Item1, deserializedData.Item2);
            Assert.That(deserializedData.Item3.Target, Is.Not.Null);
            Assert.That(deserializedData.Item3.Target, Is.SameAs(deserializedData.Item1));
            Assert.That(deserializedData.Item3.Next, Is.Not.Null);
            Assert.That(deserializedData.Item3.Next, Is.SameAs(deserializedData.Item2));
        }
        public void ThrowsIfWrongMixinInstancesInScope()
        {
            Type generatedType         = TypeFactory.GetConcreteType(typeof(BaseType1));
            var  suppliedMixinInstance = new BT3Mixin1();

            using (new MixedObjectInstantiationScope(suppliedMixinInstance))
            {
                try
                {
                    Activator.CreateInstance(generatedType);
                }
                catch (TargetInvocationException ex)
                {
                    throw ex.InnerException;
                }
            }
        }
        public void UninitializedMixin_Base()
        {
            var mixin = new BT3Mixin1();

            Dev.Null = mixin.Next;
        }
        public void UninitializedMixin_This()
        {
            var mixin = new BT3Mixin1();

            Dev.Null = mixin.Target;
        }