예제 #1
0
        public void ShouldBuildAbstractTypeThenGetDecoratedWith2Args()
        {
            MockClass3 actual    = builder.BuildAssemblyFromType <MockClass3>(typeof(MockClass3), null);
            Decorator  decorator = new ObjectDecorator(new ObjectInstantiator());

            decorator.Decorate <MockClass3>(actual);
            Assert.AreEqual("some1", actual.OtherMagic("some", 1));
        }
예제 #2
0
    public void ResolveWithInterface()
    {
        container.Register <IMockClass1, MockClass1>();
        container.Register <IMockClass2, MockClass2>();
        container.Register <IMockClass3, MockClass3>();

        MockClass1 mock1 = container.Resolve <IMockClass1>() as MockClass1;
        MockClass2 mock2 = container.Resolve <IMockClass2>() as MockClass2;
        MockClass3 mock3 = container.Resolve <IMockClass3>() as MockClass3;

        // Check that contructors have only been called once.
        Assert.AreEqual(1, MockClass1.constructorCalls);
        Assert.AreEqual(1, MockClass2.constructorCalls);
        Assert.AreEqual(1, MockClass3.constructorCalls);

        // Check that references in obejcts has been set with the correct references.
        Assert.IsNotNull(mock1.mock2);
        Assert.IsNotNull(mock1.mock3);
        Assert.IsNotNull(mock2.mock3);
        Assert.AreSame(mock1.mock2, mock2);
        Assert.AreSame(mock1.mock3, mock3);
        Assert.AreSame(mock1.mock3, mock2.mock3);
    }