Exemple #1
0
    public void InstanceReturnsNullForOtherObjectTypes()
    {
        TestableGetInstanceForm form = new TestableGetInstanceForm(typeof(ConcreteClass));

        form.OnObjectCreated(new OtherTypeOfObject());
        Assert.IsNull(form.Instance);
    }
Exemple #2
0
    public void InstanceReturnsTypesThatImplementAnInterface()
    {
        TestableGetInstanceForm form        = new TestableGetInstanceForm(typeof(IInterface));
        MyInterface             implementor = new MyInterface();

        form.OnObjectCreated(implementor);
        Assert.AreSame(implementor, form.Instance);
    }
Exemple #3
0
    public void InstanceReturnsDerivedTypes()
    {
        TestableGetInstanceForm form    = new TestableGetInstanceForm(typeof(ConcreteClass));
        DerivedClass            derived = new DerivedClass();

        form.OnObjectCreated(derived);
        Assert.AreSame(derived, form.Instance);
    }