Beispiel #1
0
        public void TestMouseOverThumb()
        {
            DummySliderControl slider = new DummySliderControl();

            slider.Bounds = new UniRectangle(10, 10, 100, 100);
            slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

            // Unknown mouse position should not be over thumb
            Assert.IsFalse(slider.MouseOverThumb);

            // Move the mouse over the thumb. The property should now return true.
            slider.ProcessMouseMove(100, 100, 50, 30);
            Assert.IsTrue(slider.MouseOverThumb);

            // Move the mouse away from the thumb, but stay over the control.
            // The property should now return false again.
            slider.ProcessMouseMove(100, 100, 50, 50);
            Assert.IsFalse(slider.MouseOverThumb);

            // Move the mouse over the thumb and then away fro mthe control.
            // The property should be false again after both movements.
            slider.ProcessMouseMove(100, 100, 50, 30);
            slider.ProcessMouseMove(100, 100, 5, 5);
            Assert.IsFalse(slider.MouseOverThumb);
        }
        public void TestMoveEvent()
        {
            using (MockFactory mockery = new MockFactory()) {
                DummySliderControl       slider     = new DummySliderControl();
                Mock <ISliderSubscriber> subscriber = mockSubscriber(mockery, slider);

                subscriber.Expects.One.Method(m => m.Moved(null, null)).WithAnyArguments();
                slider.FireMoveEvent();

                mockery.VerifyAllExpectationsHaveBeenMet();
            }
        }
Beispiel #3
0
        public void TestMoveEvent()
        {
            using (Mockery mockery = new Mockery()) {
                DummySliderControl slider     = new DummySliderControl();
                ISliderSubscriber  subscriber = mockSubscriber(mockery, slider);

                Expect.Once.On(subscriber).Method("Moved").WithAnyArguments();
                slider.FireMoveEvent();

                mockery.VerifyAllExpectationsHaveBeenMet();
            }
        }
Beispiel #4
0
        public void TestRightClickProducesNoAction()
        {
            DummySliderControl slider = new DummySliderControl();

            slider.Bounds = new UniRectangle(10, 10, 100, 100);
            slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

            // Move the mouse over the thumb and do a right-click
            slider.ProcessMouseMove(100, 100, 50, 30);
            slider.ProcessMousePress(MouseButtons.Right);

            Assert.IsFalse(slider.ThumbDepressed);
        }
Beispiel #5
0
        public void TestThumbPressing()
        {
            DummySliderControl slider = new DummySliderControl();

            slider.Bounds = new UniRectangle(10, 10, 100, 100);
            slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

            // Move the mouse over the thumb
            slider.ProcessMouseMove(100, 100, 50, 30);

            // Press the left mouse button. The thumb should now be depressed.
            slider.ProcessMousePress(MouseButtons.Left);
            Assert.IsTrue(slider.ThumbDepressed);

            // Release the left mouse button. The thumb should have risen again.
            slider.ProcessMouseRelease(MouseButtons.Left);
            Assert.IsFalse(slider.ThumbDepressed);
        }
Beispiel #6
0
        public void TestThumbDragging()
        {
            DummySliderControl slider = new DummySliderControl();

            slider.Bounds = new UniRectangle(10, 10, 100, 100);
            slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

            // Move the mouse over the thumb, press the left mouse button and drag
            // it to a new location
            slider.ProcessMouseMove(100, 100, 50, 30);
            slider.ProcessMousePress(MouseButtons.Left);
            slider.ProcessMouseMove(100, 100, 60, 50);

            // The thumb should now be moved to the new location (these are
            // absolute coordinates: the slider was at 10, 20 and we moved
            // the mouse by 10, 20, so now it's at 20, 40)
            Assert.AreEqual(20.0f, slider.ThumbX);
            Assert.AreEqual(40.0f, slider.ThumbY);
        }
Beispiel #7
0
        public void TestConstructor()
        {
            DummySliderControl slider = new DummySliderControl();

            Assert.IsNotNull(slider); // nonsense; avoids compiler warning
        }
    public void TestMouseOverThumb() {
      DummySliderControl slider = new DummySliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

      // Unknown mouse position should not be over thumb
      Assert.IsFalse(slider.MouseOverThumb);

      // Move the mouse over the thumb. The property should now return true.
      slider.ProcessMouseMove(100, 100, 50, 30);
      Assert.IsTrue(slider.MouseOverThumb);

      // Move the mouse away from the thumb, but stay over the control.
      // The property should now return false again.      
      slider.ProcessMouseMove(100, 100, 50, 50);
      Assert.IsFalse(slider.MouseOverThumb);

      // Move the mouse over the thumb and then away fro mthe control.
      // The property should be false again after both movements.
      slider.ProcessMouseMove(100, 100, 50, 30);
      slider.ProcessMouseMove(100, 100, 5, 5);
      Assert.IsFalse(slider.MouseOverThumb);
    }
 public void TestConstructor() {
   DummySliderControl slider = new DummySliderControl();
   Assert.IsNotNull(slider); // nonsense; avoids compiler warning
 }
    public void TestMoveEvent() {
      using(Mockery mockery = new Mockery()) {
        DummySliderControl slider = new DummySliderControl();
        ISliderSubscriber subscriber = mockSubscriber(mockery, slider);

        Expect.Once.On(subscriber).Method("Moved").WithAnyArguments();
        slider.FireMoveEvent();

        mockery.VerifyAllExpectationsHaveBeenMet();
      }
    }
    public void TestRightClickProducesNoAction() {
      DummySliderControl slider = new DummySliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

      // Move the mouse over the thumb and do a right-click
      slider.ProcessMouseMove(100, 100, 50, 30);
      slider.ProcessMousePress(MouseButtons.Right);

      Assert.IsFalse(slider.ThumbDepressed);
    }
    public void TestThumbDragging() {
      DummySliderControl slider = new DummySliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

      // Move the mouse over the thumb, press the left mouse button and drag
      // it to a new location
      slider.ProcessMouseMove(100, 100, 50, 30);
      slider.ProcessMousePress(MouseButtons.Left);
      slider.ProcessMouseMove(100, 100, 60, 50);

      // The thumb should now be moved to the new location (these are
      // absolute coordinates: the slider was at 10, 20 and we moved
      // the mouse by 10, 20, so now it's at 20, 40)
      Assert.AreEqual(20.0f, slider.ThumbX);
      Assert.AreEqual(40.0f, slider.ThumbY);
    }
    public void TestThumbPressing() {
      DummySliderControl slider = new DummySliderControl();
      slider.Bounds = new UniRectangle(10, 10, 100, 100);
      slider.ReportedThumbRegion = new RectangleF(10, 20, 100, 20);

      // Move the mouse over the thumb
      slider.ProcessMouseMove(100, 100, 50, 30);

      // Press the left mouse button. The thumb should now be depressed.
      slider.ProcessMousePress(MouseButtons.Left);
      Assert.IsTrue(slider.ThumbDepressed);

      // Release the left mouse button. The thumb should have risen again.
      slider.ProcessMouseRelease(MouseButtons.Left);
      Assert.IsFalse(slider.ThumbDepressed);
    }