Example #1
0
        public async Task When_PauseResume()
        {
            var ct = CancellationToken.None;             // Not supported yet by test engine

            object v1, v2, v3;
            var    target = new AnimTarget();
            var    sut    = new ObjectAnimationUsingKeyFrames
            {
                BeginTime      = TimeSpan.Zero,
                RepeatBehavior = new RepeatBehavior(),
                FillBehavior   = FillBehavior.HoldEnd,
                KeyFrames      =
                {
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.Zero, Value = v1 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(1), Value = v2 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(10), Value = v3 = new object()
                    },
                }
            };

            Storyboard.SetTarget(sut, target);
            Storyboard.SetTargetProperty(sut, nameof(target.Value));

            ((ITimeline)sut).Begin();
            await target.GetValue(ct, 2);

            await Task.Yield();

            ((ITimeline)sut).Pause();

            await Task.Delay(100, ct);

            target.History.Should().BeEquivalentTo(v1, v2);
            sut.State.Should().Be(Timeline.TimelineState.Paused);

            ((ITimeline)sut).Resume();
            await target.GetValue(ct, 3);

            await Task.Yield();

            target.History.Should().BeEquivalentTo(v1, v2, v3);
            sut.State.Should().Be(Timeline.TimelineState.Filling);
        }
Example #2
0
        public async Task When_RepeatForever()
        {
            var ct = CancellationToken.None;             // Not supported yet by test engine

            object v1, v2, v3;
            var    target = new AnimTarget();
            var    sut    = new ObjectAnimationUsingKeyFrames
            {
                BeginTime      = TimeSpan.Zero,
                RepeatBehavior = RepeatBehavior.Forever,
                FillBehavior   = FillBehavior.HoldEnd,
                KeyFrames      =
                {
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.Zero, Value = v1 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(1), Value = v2 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(2), Value = v3 = new object()
                    },
                }
            };

            Storyboard.SetTarget(sut, target);
            Storyboard.SetTargetProperty(sut, nameof(target.Value));

            ((ITimeline)sut).Begin();
            await target.GetValue(ct, 9);

            await Task.Yield();

            try
            {
                target.History.Count.Should().BeGreaterThan(9);
                target.History.Take(9).Should().BeEquivalentTo(v1, v2, v3, v1, v2, v3, v1, v2, v3);
                sut.State.Should().Be(Timeline.TimelineState.Active);
            }
            finally
            {
                ((ITimeline)sut).Stop();
            }
        }
Example #3
0
        public void When_FirstFrameTimeIsZero_Then_ItsAppliedSyncOnStart()
        {
            object v1, v2, v3;
            var    target = new AnimTarget();
            var    sut    = new ObjectAnimationUsingKeyFrames
            {
                BeginTime      = TimeSpan.Zero,
                RepeatBehavior = new RepeatBehavior(),
                FillBehavior   = FillBehavior.HoldEnd,
                KeyFrames      =
                {
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.Zero, Value = v1 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(1), Value = v2 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(2), Value = v3 = new object()
                    },
                }
            };

            Storyboard.SetTarget(sut, target);
            Storyboard.SetTargetProperty(sut, nameof(target.Value));

            try
            {
                ((ITimeline)sut).Begin();

                target.Value.Should().Be(v1);
            }
            finally
            {
                ((ITimeline)sut).Stop();
            }
        }
Example #4
0
        public async Task When_RepeatDuration()
        {
            var ct = CancellationToken.None;             // Not supported yet by test engine

            object v1, v2, v3;
            var    target = new AnimTarget();
            var    sut    = new ObjectAnimationUsingKeyFrames
            {
                BeginTime      = TimeSpan.Zero,
                RepeatBehavior = new RepeatBehavior(TimeSpan.FromMilliseconds(100 * 3)),
                FillBehavior   = FillBehavior.HoldEnd,
                KeyFrames      =
                {
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.Zero, Value = v1 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(50), Value = v2 = new object()
                    },
                    new ObjectKeyFrame {
                        KeyTime = TimeSpan.FromMilliseconds(100), Value = v3 = new object()
                    },
                }
            };

            Storyboard.SetTarget(sut, target);
            Storyboard.SetTargetProperty(sut, nameof(target.Value));

            ((ITimeline)sut).Begin();
            await target.GetValue(ct, 9);

            await Task.Delay(100, ct);             // Give opportunity to (wrongly) repeat again some frames

            target.History.Take(9) /* Helps laggish CI! */.Should().BeEquivalentTo(v1, v2, v3, v1, v2, v3, v1, v2, v3);
            sut.State.Should().Be(Timeline.TimelineState.Filling);
        }