Ejemplo n.º 1
0
        public void TestTickSnapping()
        {
            var slider = new Slider { TickFrequency = 1 };

            slider.Value = 0.55f;
            slider.SnapToClosestTick();
            Assert.AreEqual(1f, slider.Value);

            slider.Value = 0.45f;
            slider.SnapToClosestTick();
            Assert.AreEqual(0f, slider.Value);

            slider.TickFrequency = 20;
            slider.Value = 0.44f;
            slider.ShouldSnapToTicks = true;
            Utilities.AssertAreNearlyEqual(0.45f, slider.Value);

            slider.TickFrequency = 5;
            Utilities.AssertAreNearlyEqual(0.4f, slider.Value);

            slider.Value = 0.22f;
            Utilities.AssertAreNearlyEqual(0.2f, slider.Value);

            slider.Step = 0.16f;
            slider.Increase();
            Utilities.AssertAreNearlyEqual(0.4f, slider.Value);
        }
Ejemplo n.º 2
0
        public void TestIncreateDecrease()
        {
            var slider = new Slider { Value = 0.5f };

            slider.Increase();
            Assert.AreEqual(0.6f, slider.Value);
            slider.Decrease();
            Assert.AreEqual(0.5f, slider.Value);

            slider.Step = 0.01f;
            slider.Decrease();
            Assert.AreEqual(0.49f, slider.Value);
            slider.Increase();
            Assert.AreEqual(0.5f, slider.Value);

            slider.Step = 5f;
            slider.Increase();
            Assert.AreEqual(1f, slider.Value);
            slider.Decrease();
            Assert.AreEqual(0f, slider.Value);

            slider.Step = 0f;
            slider.ShouldSnapToTicks = true;
            slider.Increase();
            Assert.AreEqual(0.1f, slider.Value);
            slider.Value = 0.5f;
            slider.Decrease();
            Assert.AreEqual(0.4f, slider.Value);

            slider.Step = 0.16f;
            slider.Increase();
            Assert.AreEqual(0.6f, slider.Value);
        }