public void TestSetManagedControl_ShouldSetADefaultControlManagerCreator() { //---------------Set up test pack------------------- HabaneroMenu.Item menuItem = new HabaneroMenu.Item(null, TestUtil.GetRandomString()); var control = new ControlHabaneroFake(); //---------------Assert PreConditions--------------- Assert.IsNull(menuItem.ControlManagerCreator); //---------------Execute Test ---------------------- menuItem.ManagedControl = control; Assert.IsNotNull(menuItem.ControlManagerCreator); var controlManager = menuItem.ControlManagerCreator(null); //---------------Test Result ----------------------- Assert.AreSame(control, controlManager.Control); }
public void TestSetControlManagerCreator() { //---------------Set up test pack------------------- HabaneroMenu.Item menuItem = new HabaneroMenu.Item(null, TestUtil.GetRandomString()); //---------------Assert PreConditions--------------- Assert.IsNull(menuItem.ControlManagerCreator); //---------------Execute Test ---------------------- menuItem.ControlManagerCreator += delegate { return new ControlManagerStub(); }; IControlManager controlManager = menuItem.ControlManagerCreator(null); //---------------Test Result ----------------------- Assert.IsNotNull(menuItem.ControlManagerCreator); Assert.IsNotNull(controlManager); Assert.IsInstanceOf(typeof(ControlManagerStub), controlManager); }