public void GetSelfAndAncestors() { var animationA = new TimelineGroup(); var animationB = new SingleFromToByAnimation(); var animationC = new SingleFromToByAnimation(); var animationD = new TimelineGroup(); var animationE = new TimelineGroup(); var animationF = new SingleFromToByAnimation(); var animationG = new TimelineGroup(); animationA.Add(animationB); animationA.Add(animationC); animationA.Add(animationD); animationD.Add(animationE); animationD.Add(animationF); animationE.Add(animationG); Assert.That(() => AnimationHelper.GetSelfAndAncestors(null), Throws.TypeOf <ArgumentNullException>()); var animationInstance = animationA.CreateInstance(); var ancestors = animationInstance.Children[2].Children[0].GetSelfAndAncestors().ToArray(); Assert.AreEqual(3, ancestors.Length); Assert.AreEqual(animationInstance.Children[2].Children[0], ancestors[0]); Assert.AreEqual(animationInstance.Children[2], ancestors[1]); Assert.AreEqual(animationInstance, ancestors[2]); }
public void GetDescendantsDepthFirst() { var animationA = new TimelineGroup(); var animationB = new SingleFromToByAnimation(); var animationC = new SingleFromToByAnimation(); var animationD = new TimelineGroup(); var animationE = new TimelineGroup(); var animationF = new SingleFromToByAnimation(); var animationG = new TimelineGroup(); animationA.Add(animationB); animationA.Add(animationC); animationA.Add(animationD); animationD.Add(animationE); animationD.Add(animationF); animationE.Add(animationG); Assert.That(() => AnimationHelper.GetDescendants(null), Throws.TypeOf <ArgumentNullException>()); var animationInstance = animationA.CreateInstance(); var descendants = animationInstance.GetDescendants().ToArray(); Assert.AreEqual(6, descendants.Length); Assert.AreEqual(animationInstance.Children[0], descendants[0]); Assert.AreEqual(animationInstance.Children[1], descendants[1]); Assert.AreEqual(animationInstance.Children[2], descendants[2]); Assert.AreEqual(animationInstance.Children[2].Children[0], descendants[3]); Assert.AreEqual(animationInstance.Children[2].Children[0].Children[0], descendants[4]); Assert.AreEqual(animationInstance.Children[2].Children[1], descendants[5]); }
public void CreateInstanceTest() { var animation1 = new SingleFromToByAnimation(); var animation2 = new SingleFromToByAnimation(); var animation3 = new SingleFromToByAnimation(); var childGroup = new TimelineGroup(); childGroup.Add(animation2); childGroup.Add(animation3); var rootGroup = new TimelineGroup(); rootGroup.Add(animation1); rootGroup.Add(childGroup); var animationInstance = rootGroup.CreateInstance(); Assert.IsNotNull(animationInstance); Assert.AreEqual(2, animationInstance.Children.Count); Assert.That(animationInstance.Children[0], Is.TypeOf <AnimationInstance <float> >()); Assert.That(animationInstance.Children[0].Animation, Is.EqualTo(animation1)); Assert.That(animationInstance.Children[1], Is.TypeOf <AnimationInstance>()); Assert.That(animationInstance.Children[1].Animation, Is.EqualTo(childGroup)); Assert.That(animationInstance.Children[1].Children[0], Is.TypeOf <AnimationInstance <float> >()); Assert.That(animationInstance.Children[1].Children[0].Animation, Is.EqualTo(animation2)); Assert.That(animationInstance.Children[1].Children[1], Is.TypeOf <AnimationInstance <float> >()); Assert.That(animationInstance.Children[1].Children[1].Animation, Is.EqualTo(animation3)); }
public void CreateInstanceTest() { var animation1 = new SingleFromToByAnimation(); var animation2 = new SingleFromToByAnimation(); var animation3 = new SingleFromToByAnimation(); var childGroup = new TimelineGroup(); childGroup.Add(animation2); childGroup.Add(animation3); var rootGroup = new TimelineGroup(); rootGroup.Add(animation1); rootGroup.Add(childGroup); var animationInstance = rootGroup.CreateInstance(); Assert.IsNotNull(animationInstance); Assert.AreEqual(2, animationInstance.Children.Count); Assert.That(animationInstance.Children[0], Is.TypeOf<AnimationInstance<float>>()); Assert.That(animationInstance.Children[0].Animation, Is.EqualTo(animation1)); Assert.That(animationInstance.Children[1], Is.TypeOf<AnimationInstance>()); Assert.That(animationInstance.Children[1].Animation, Is.EqualTo(childGroup)); Assert.That(animationInstance.Children[1].Children[0], Is.TypeOf<AnimationInstance<float>>()); Assert.That(animationInstance.Children[1].Children[0].Animation, Is.EqualTo(animation2)); Assert.That(animationInstance.Children[1].Children[1], Is.TypeOf<AnimationInstance<float>>()); Assert.That(animationInstance.Children[1].Children[1].Animation, Is.EqualTo(animation3)); }
public void GetRoot() { var animationA = new TimelineGroup(); var animationB = new SingleFromToByAnimation(); var animationC = new SingleFromToByAnimation(); var animationD = new TimelineGroup(); var animationE = new TimelineGroup(); var animationF = new SingleFromToByAnimation(); var animationG = new TimelineGroup(); animationA.Add(animationB); animationA.Add(animationC); animationA.Add(animationD); animationD.Add(animationE); animationD.Add(animationF); animationE.Add(animationG); Assert.That(() => AnimationHelper.GetRoot(null), Throws.TypeOf <ArgumentNullException>()); var animationInstance = animationA.CreateInstance(); Assert.AreEqual(animationInstance, animationInstance.GetRoot()); Assert.AreEqual(animationInstance, animationInstance.Children[2].Children[0].GetRoot()); }
public void ShouldThrowWhenOwnerHasChildren() { var timelineGroup = new TimelineGroup(); var animationInstance = timelineGroup.CreateInstance(); var collection = new AnimationInstanceCollection(animationInstance); }
public void ShouldThrowWhenOwnerHasChildren() { var timelineGroup = new TimelineGroup(); var animationInstance = timelineGroup.CreateInstance(); var collection = new AnimationInstanceCollection(animationInstance); }
public void GetSubtreeDepthFirst() { var animationA = new TimelineGroup(); var animationB = new SingleFromToByAnimation(); var animationC = new SingleFromToByAnimation(); var animationD = new TimelineGroup(); var animationE = new TimelineGroup(); var animationF = new SingleFromToByAnimation(); var animationG = new TimelineGroup(); animationA.Add(animationB); animationA.Add(animationC); animationA.Add(animationD); animationD.Add(animationE); animationD.Add(animationF); animationE.Add(animationG); Assert.That(() => AnimationHelper.GetSubtree(null), Throws.TypeOf<ArgumentNullException>()); var animationInstance = animationA.CreateInstance(); var descendants = animationInstance.Children[2].GetSubtree().ToArray(); Assert.AreEqual(4, descendants.Length); Assert.AreEqual(animationInstance.Children[2], descendants[0]); Assert.AreEqual(animationInstance.Children[2].Children[0], descendants[1]); Assert.AreEqual(animationInstance.Children[2].Children[0].Children[0], descendants[2]); Assert.AreEqual(animationInstance.Children[2].Children[1], descendants[3]); }
public void GetSelfAndAncestors() { var animationA = new TimelineGroup(); var animationB = new SingleFromToByAnimation(); var animationC = new SingleFromToByAnimation(); var animationD = new TimelineGroup(); var animationE = new TimelineGroup(); var animationF = new SingleFromToByAnimation(); var animationG = new TimelineGroup(); animationA.Add(animationB); animationA.Add(animationC); animationA.Add(animationD); animationD.Add(animationE); animationD.Add(animationF); animationE.Add(animationG); Assert.That(() => AnimationHelper.GetSelfAndAncestors(null), Throws.TypeOf<ArgumentNullException>()); var animationInstance = animationA.CreateInstance(); var ancestors = animationInstance.Children[2].Children[0].GetSelfAndAncestors().ToArray(); Assert.AreEqual(3, ancestors.Length); Assert.AreEqual(animationInstance.Children[2].Children[0], ancestors[0]); Assert.AreEqual(animationInstance.Children[2], ancestors[1]); Assert.AreEqual(animationInstance, ancestors[2]); }
public void GetRoot() { var animationA = new TimelineGroup(); var animationB = new SingleFromToByAnimation(); var animationC = new SingleFromToByAnimation(); var animationD = new TimelineGroup(); var animationE = new TimelineGroup(); var animationF = new SingleFromToByAnimation(); var animationG = new TimelineGroup(); animationA.Add(animationB); animationA.Add(animationC); animationA.Add(animationD); animationD.Add(animationE); animationD.Add(animationF); animationE.Add(animationG); Assert.That(() => AnimationHelper.GetRoot(null), Throws.TypeOf<ArgumentNullException>()); var animationInstance = animationA.CreateInstance(); Assert.AreEqual(animationInstance, animationInstance.GetRoot()); Assert.AreEqual(animationInstance, animationInstance.Children[2].Children[0].GetRoot()); }