public void Check_Transitions_Interpolation_Positive_Bounds_Clamp()
        {
            var clock = new MockGlobalClock();

            using (UnitTestApplication.Start(new TestServices(globalClock: clock)))
            {
                var border = new Border
                {
                    Transitions =
                    {
                        new DoubleTransition
                        {
                            Duration = TimeSpan.FromSeconds(1),
                            Property = Border.OpacityProperty,
                        }
                    }
                };

                border.Opacity = 0;

                clock.Pulse(TimeSpan.FromSeconds(0));
                clock.Pulse(TimeSpan.FromMilliseconds(1001));

                Assert.Equal(0, border.Opacity);
            }
        }
Esempio n. 2
0
        public void Transition_On_StyledProperty_Is_Freed()
        {
            var clock = new MockGlobalClock();

            using (UnitTestApplication.Start(new TestServices(globalClock: clock)))
            {
                Func <Border> run = () =>
                {
                    var border = new Border
                    {
                        Transitions =
                        {
                            new DoubleTransition
                            {
                                Duration = TimeSpan.FromSeconds(1),
                                Property = Border.OpacityProperty,
                            }
                        }
                    };

                    border.Opacity = 0;

                    clock.Pulse(TimeSpan.FromSeconds(0));
                    clock.Pulse(TimeSpan.FromSeconds(0.5));

                    Assert.Equal(0.5, border.Opacity);

                    clock.Pulse(TimeSpan.FromSeconds(1));

                    Assert.Equal(0, border.Opacity);
                    return(border);
                };

                var result = run();

                dotMemory.Check(memory =>
                                Assert.Equal(0, memory.GetObjects(where => where.Type.Is <TransitionInstance>()).ObjectsCount));
            }
        }
Esempio n. 3
0
        public void TransitionInstance_With_Zero_Duration_Is_Completed_On_First_Tick()
        {
            var clock = new MockGlobalClock();

            using (UnitTestApplication.Start(new TestServices(globalClock: clock)))
            {
                int i    = 0;
                var inst = new TransitionInstance(clock, TimeSpan.Zero).Subscribe(nextValue =>
                {
                    switch (i++)
                    {
                    case 0: Assert.Equal(0, nextValue); break;

                    case 1: Assert.Equal(1d, nextValue); break;
                    }
                });

                clock.Pulse(TimeSpan.FromMilliseconds(10));
            }
        }