/// <summary>Mocks a subscriber for the events of an option</summary> /// <param name="option">Option to mock an event subscriber for</param> /// <returns>The mocked event subscriber</returns> private IOptionSubscriber mockSubscriber(OptionControl option) { IOptionSubscriber mockedSubscriber = this.mockery.NewMock <IOptionSubscriber>(); option.Changed += new EventHandler(mockedSubscriber.Changed); return(mockedSubscriber); }
public void TestOptionToggleByMouse() { OptionControl option = new OptionControl(); option.Bounds = new UniRectangle(10, 10, 100, 100); IOptionSubscriber mockedSubscriber = mockSubscriber(option); Expect.Once.On(mockedSubscriber).Method("Changed").WithAnyArguments(); Assert.IsFalse(option.Selected); // Move the mouse over the button and do a left-click option.ProcessMouseMove(0, 0, 50, 50); option.ProcessMousePress(MouseButtons.Left); option.ProcessMouseRelease(MouseButtons.Left); this.mockery.VerifyAllExpectationsHaveBeenMet(); Assert.IsTrue(option.Selected); }