public void GetValueTest() { var timelineClip = new TimelineClip(); timelineClip.GetState(TimeSpan.Zero); // Should not crash. timelineClip.GetAnimationTime(TimeSpan.FromSeconds(0.0)); // Should not crash. timelineClip.Delay = TimeSpan.FromSeconds(100); timelineClip.Speed = 1.0f; timelineClip.ClipStart = TimeSpan.FromSeconds(10.5); timelineClip.ClipEnd = TimeSpan.FromSeconds(11.5); timelineClip.ClipOffset = TimeSpan.FromSeconds(-0.5); timelineClip.Duration = TimeSpan.FromSeconds(4.0); timelineClip.LoopBehavior = LoopBehavior.Oscillate; timelineClip.Timeline = new TimelineClip { Timeline = new SingleFromToByAnimation { Duration = TimeSpan.FromSeconds(4.0) }, Delay = TimeSpan.FromSeconds(10), Duration = null, Speed = 2.0f, }; // Delayed Assert.AreEqual(AnimationState.Delayed, timelineClip.GetState(TimeSpan.FromSeconds(99.0))); Assert.IsFalse(timelineClip.GetAnimationTime(TimeSpan.FromSeconds(99.0)).HasValue); // Playing Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(100.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(100.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(100.5))); Assert.AreEqual(TimeSpan.FromSeconds(10.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(100.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(101.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(101.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(101.5))); Assert.AreEqual(TimeSpan.FromSeconds(11.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(101.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(102.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(102.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(102.5))); Assert.AreEqual(TimeSpan.FromSeconds(10.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(102.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(103.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(103.0))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(103.5))); Assert.AreEqual(TimeSpan.FromSeconds(11.5), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(103.5))); Assert.AreEqual(AnimationState.Playing, timelineClip.GetState(TimeSpan.FromSeconds(104.0))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(104.0))); // Filling Assert.AreEqual(AnimationState.Filling, timelineClip.GetState(TimeSpan.FromSeconds(104.5))); Assert.AreEqual(TimeSpan.FromSeconds(11.0), timelineClip.GetAnimationTime(TimeSpan.FromSeconds(104.5))); timelineClip.FillBehavior = FillBehavior.Stop; // Stopped Assert.AreEqual(AnimationState.Stopped, timelineClip.GetState(TimeSpan.FromSeconds(104.5))); Assert.IsFalse(timelineClip.GetAnimationTime(TimeSpan.FromSeconds(104.5)).HasValue); }
public void ShouldThrowWhenClipIsInvalid() { var timelineClip = new TimelineClip { Timeline = new SingleFromToByAnimation(), ClipStart = TimeSpan.FromSeconds(0.75), ClipEnd = TimeSpan.FromSeconds(0.25), }; Assert.That(() => timelineClip.GetTotalDuration(), Throws.TypeOf<InvalidAnimationException>()); Assert.That(() => timelineClip.GetState(TimeSpan.Zero), Throws.TypeOf<InvalidAnimationException>()); Assert.That(() => timelineClip.GetAnimationTime(TimeSpan.Zero), Throws.TypeOf<InvalidAnimationException>()); }