Ejemplo n.º 1
0
    public void SelectingTreeNodePopulatesObjectListWithObjectsThatImplementAnInterface()
    {
        Assembly source_assembly = typeof(IInterface).Assembly;

        Assembly[] assemblies = { source_assembly, typeof(Object).Assembly };
        ObjectPool.pool = new ArrayList()
        {
            new MyMyInterface1(), new MyInterface(), new MyMyInterface3()
        };
        GetInstanceForm   form = new GetInstanceForm(assemblies, source_assembly, typeof(IInterface));
        TreeViewEventArgs ev   = new TreeViewEventArgs(form.treeTypes.Nodes[0]);

        ev.Node.Tag = typeof(IInterface);
        form.treeTypes_AfterSelect(null, ev);
        Assert.AreEqual(3, form.listBoxObjects.Items.Count);
    }
Ejemplo n.º 2
0
    public void SelectingTreeNodePopulatesObjectListWithObjectsThatAreOrDeriveFromType()
    {
        Assembly source_assembly = typeof(Parent).Assembly;

        Assembly[] assemblies = { source_assembly, typeof(Object).Assembly };
        ObjectPool.pool = new ArrayList()
        {
            new B21(), "not this one", new Daughter(), "nor this one", new Son()
        };
        GetInstanceForm   form = new GetInstanceForm(assemblies, source_assembly, typeof(Parent));
        TreeViewEventArgs ev   = new TreeViewEventArgs(form.treeTypes.Nodes[0]);

        ev.Node.Tag = typeof(Son);
        form.treeTypes_AfterSelect(null, ev);
        Assert.AreEqual(2, form.listBoxObjects.Items.Count);
    }
Ejemplo n.º 3
0
    public void SelectingTreeNodeDisablesObjectSelectButton()
    {
        Assembly source_assembly = typeof(Parent).Assembly;

        Assembly[] assemblies = { source_assembly, typeof(Object).Assembly };
        ObjectPool.pool = new ArrayList()
        {
        };
        GetInstanceForm form = new GetInstanceForm(assemblies, source_assembly, typeof(Parent));

        form.buttonSelect.Enabled = true;
        TreeViewEventArgs ev = new TreeViewEventArgs(form.treeTypes.Nodes[0]);

        ev.Node.Tag = typeof(Parent);
        form.treeTypes_AfterSelect(null, ev);
        Assert.IsFalse(form.buttonSelect.Enabled);
    }
Ejemplo n.º 4
0
    public void SelectingTreeNodeClearsObjectListBeforePopulating()
    {
        Assembly source_assembly = typeof(Parent).Assembly;

        Assembly[] assemblies = { source_assembly, typeof(Object).Assembly };
        ObjectPool.pool = new ArrayList()
        {
        };
        GetInstanceForm form = new GetInstanceForm(assemblies, source_assembly, typeof(Parent));

        form.listBoxObjects.Items.Add("something to the list to simulate data from last populate");
        TreeViewEventArgs ev = new TreeViewEventArgs(form.treeTypes.Nodes[0]);

        ev.Node.Tag = typeof(Parent);
        form.treeTypes_AfterSelect(null, ev);
        Assert.AreEqual(0, form.listBoxObjects.Items.Count);
    }