public void InsertItemTest() { ModuleInstanceCollection mic; ModuleInstance mi; Package package; // // Setup the test. // package = new Package(); mic = new ModuleInstanceCollection(package); mic.Add(new ModuleInstance()); mi = new ModuleInstance(); // // Run the test. // mic.Insert(0, mi); // // Verify the test. // Assert.AreSame(mi, mic[0]); }
protected override void OnInit(EventArgs e) { ModuleInstanceCollection input = new ModuleInstanceCollection(); input.LoadByParentModuleInstanceID(base.CurrentModule.ModuleInstanceID, (base.CurrentPerson != null) ? base.CurrentPerson.PersonID : -1); foreach (ModuleInstance instance in input) { if (instance.Permissions.Allowed(OperationType.View, base.CurrentUser)) { PropertyInfo property = base.GetType().GetProperty(instance.TemplateFrameName); if (property == null) { throw new ApplicationException(string.Format("Could not find frame named '{0}' in {1}", instance.TemplateFrameName, base.GetType().Name)); } Control control = (Control)property.GetValue(this, null); if (control == null) { throw new ApplicationException(string.Format("Could not load frame named '{0}'", instance.TemplateFrameName)); } PortalControl portalControl = this.LoadModule(instance); if (portalControl != null) { control.Controls.Add(portalControl); } } } }
public void SetPackageTest() { ModuleInstanceCollection mic; ModuleInstance mi; Package package; // // Setup the test. // package = new Package(); mic = new ModuleInstanceCollection(null); mi = new ModuleInstance(); mic.Add(mi); // // Run the test. // mic.Owner = package; // // Verify the test. // Assert.AreSame(package, mi.Package); }
public void RemoveItemTest() { ModuleInstanceCollection mic; ModuleInstance mi; Package package; // // Setup the test. // package = new Package(); mic = new ModuleInstanceCollection(package); mi = new ModuleInstance(); mic.Add(mi); // // Run the test. // mic.Remove(mi); // // Verify the test. // Assert.AreEqual(null, mi.Package); Assert.AreEqual(0, mic.Count); }
public void SetItemTest() { ModuleInstanceCollection mic; ModuleInstance mi1, mi2; Package package, package2; // // Setup the test. // package = new Package(); package2 = new Package(); mic = new ModuleInstanceCollection(package); mi1 = new ModuleInstance(); mi1.Package = package2; mi2 = new ModuleInstance(); mic.Add(mi1); // // Run the test. // mic[0] = mi2; // // Verify the test. // Assert.AreSame(mi2, mic[0]); Assert.AreEqual(1, mic.Count); Assert.AreEqual(null, mi1.Package); Assert.AreEqual(package, mi2.Package); }
public void EmptyConstructorTest() { ModuleInstanceCollection mic; // // No setup needed. // // // Run the test. // mic = new ModuleInstanceCollection(); // // Verify the test. // Assert.AreSame(null, mic.Owner); }
public void ConstructorTest() { ModuleInstanceCollection mic; Package package; // // Setup the test. // package = new Package(); // // Run the test. // mic = new ModuleInstanceCollection(package); // // Verify the test. // Assert.AreSame(package, mic.Owner); }