public void FilterInterfacesFromAssemblyTypes() { Type type_under_test = typeof(System.Collections.ICollection); System.Collections.Generic.List <Type> filtered = GetInstanceForm.GetFilteredTypes(type_under_test.Assembly.GetTypes(), type_under_test); Assert.IsFalse(filtered.Contains(type_under_test)); }
public void ComboBoxMustBeSortedAscendingByAssemblyName() { Assembly[] assemblies = { typeof(Parent).Assembly, typeof(String).Assembly }; GetInstanceForm form = new GetInstanceForm(assemblies, typeof(Parent).Assembly, typeof(Parent)); Assert.AreEqual(2, form.comboBoxAssembly.Items.Count); Assert.AreEqual(assemblies[1], form.comboBoxAssembly.Items[0] as Assembly); Assert.AreEqual(assemblies[0], form.comboBoxAssembly.Items[1] as Assembly); }
public void ExpandTypeFromAssemblyArgument() { Assembly source_assembly = typeof(Parent).Assembly; Assembly[] assemblies = { source_assembly, typeof(Object).Assembly }; GetInstanceForm form = new GetInstanceForm(assemblies, source_assembly, typeof(Object)); Assert.AreEqual(source_assembly.FullName, form.comboBoxAssembly.Text); }
public void SelectButtonCachesHighlightedObjectAsInstance() { TestableGetInstanceForm form = new TestableGetInstanceForm(typeof(String)); ObjectPool.pool = new ArrayList() { "A", "B", "C" }; GetInstanceForm.PopulateObjectList(form.listBoxObjects, ObjectPool.pool, typeof(String)); form.listBoxObjects.SelectedIndex = 1; form.buttonSelect_Click(null, null); Assert.AreEqual("B", form.Instance); }
public void AddingObjectToPoolRefreshesObjectList() { Assembly source_assembly = typeof(Parent).Assembly; Assembly[] assemblies = { source_assembly }; ObjectPool.pool = new ArrayList() { }; GetInstanceForm form = new GetInstanceForm(assemblies, source_assembly, typeof(Parent)); form.Show(); form.instance = new Son(); ObjectPool.Add(form.instance); Assert.AreEqual(1, form.listBoxObjects.Items.Count); form.Close(); }
public void HighlightSelectButtonOnObjectListSelection() { Assembly source_assembly = typeof(String).Assembly; Assembly[] assemblies = { source_assembly, typeof(Object).Assembly }; ObjectPool.pool = new ArrayList() { "Object 1", "Object 2" }; GetInstanceForm form = new GetInstanceForm(assemblies, source_assembly, typeof(Parent)); form.listBoxObjects.Items.Add("Object 1"); form.listBoxObjects.SelectedIndex = 0; form.listBoxObjects_SelectedIndexChanged(null, null); Assert.IsTrue(form.buttonSelect.Enabled); }
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); }
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); }
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); }
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); }