示例#1
0
        /// <summary>Mocks a receiver for the input processing of a control</summary>
        /// <param name="screen">Screen to mock an input receiver on</param>
        /// <returns>The mocked input receiver</returns>
        private Mock <IInputReceiver> mockReceiver(Screen screen)
        {
            Mock <IInputReceiver> mockedReceiver = this.mockery.CreateMock <IInputReceiver>();

            DelegatingControl delegatingControl = new DelegatingControl(mockedReceiver.MockObject);

            screen.Desktop.Children.Add(delegatingControl);
            screen.FocusedControl = delegatingControl;

            return(mockedReceiver);
        }
示例#2
0
        public void TestNoFocusChangeOnHandledDirectionalCommand()
        {
            Screen screen = new Screen(100.0f, 100.0f);
            Mock <IInputReceiver> mockedReceiver = mockReceiver(screen);
            DelegatingControl     one            = new DelegatingControl(mockedReceiver.MockObject);

            one.Bounds = new UniRectangle(40, 10, 20, 20);
            Controls.Desktop.ButtonControl two = new Controls.Desktop.ButtonControl();
            two.Bounds = new UniRectangle(40, 40, 20, 20);

            screen.Desktop.Children.Add(one);
            screen.Desktop.Children.Add(two);

            mockedReceiver.Expects.One.MethodWith(m => m.InjectCommand(Command.Down));

            screen.FocusedControl = one;
            screen.InjectCommand(Command.Down);

            Assert.AreSame(one, screen.FocusedControl);

            this.mockery.VerifyAllExpectationsHaveBeenMet();
        }
示例#3
0
    /// <summary>Mocks a receiver for the input processing of a control</summary>
    /// <param name="screen">Screen to mock an input receiver on</param>
    /// <returns>The mocked input receiver</returns>
    private IInputReceiver mockReceiver(Screen screen) {
      IInputReceiver mockedReceiver = this.mockery.NewMock<IInputReceiver>();

      DelegatingControl delegatingControl = new DelegatingControl(mockedReceiver);
      screen.Desktop.Children.Add(delegatingControl);
      screen.FocusedControl = delegatingControl;

      return mockedReceiver;
    }
示例#4
0
    public void TestNoFocusChangeOnHandledDirectionalCommand() {
      Screen screen = new Screen(100.0f, 100.0f);
      IInputReceiver mockedReceiver = mockReceiver(screen);
      DelegatingControl one = new DelegatingControl(mockedReceiver);
      one.Bounds = new UniRectangle(40, 10, 20, 20);
      Controls.Desktop.ButtonControl two = new Controls.Desktop.ButtonControl();
      two.Bounds = new UniRectangle(40, 40, 20, 20);

      screen.Desktop.Children.Add(one);
      screen.Desktop.Children.Add(two);

      Expect.Once.On(mockedReceiver).Method("InjectCommand").WithAnyArguments();

      screen.FocusedControl = one;
      screen.InjectCommand(Command.Down);

      Assert.AreSame(one, screen.FocusedControl);

      this.mockery.VerifyAllExpectationsHaveBeenMet();
    }