public void RegisterPropertyTweenerTest() { TweenShark.Initialize(new TweenSharkTickImpl(), new NullLogger()); var type = typeof(TweenShark); var info = type.GetField("_core", BindingFlags.NonPublic | BindingFlags.Static); var core = (TweenSharkCore)info.GetValue(null); // the core must be created Assert.IsInstanceOfType(core, typeof(TweenSharkCore)); var param0 = new PrivateObject(core); var accessor = new TweenSharkCore_Accessor(param0); var beforeCount = accessor._registeredPropertyTweeners.Count; // if we overwrite an existing type the number of registered tweeners must not change TweenShark.RegisterPropertyTweener(typeof(SimpleTweenerImpl <SByte>), typeof(SByte)); Assert.AreEqual(beforeCount, accessor._registeredPropertyTweeners.Count); // the tweener for sbyte must be overwritten Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(SByte).FullName], typeof(SimpleTweenerImpl <SByte>)); // if we overwrite an existing type the number of registered tweeners must change TweenShark.RegisterPropertyTweener(typeof(SimpleTweenerImpl <SByte>), typeof(TweeningTestObject)); Assert.AreEqual(beforeCount + 1, accessor._registeredPropertyTweeners.Count); // the tweener for sbyte must be overwritten Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(TweeningTestObject).FullName], typeof(SimpleTweenerImpl <SByte>)); }
public void InitializeTest() { TweenShark.Initialize(new TweenSharkTickImpl(), new NullLogger()); var type = typeof(TweenShark); var info = type.GetField("_core", BindingFlags.NonPublic | BindingFlags.Static); var core = (TweenSharkCore)info.GetValue(null); // the core must be created Assert.IsInstanceOfType(core, typeof(TweenSharkCore)); var param0 = new PrivateObject(core); var accessor = new TweenSharkCore_Accessor(param0); // the standard property tweeners must be registered Assert.AreEqual(10, accessor._registeredPropertyTweeners.Count); // check that all tweeners are registerd correctly Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(SByte).FullName], typeof(SignedByteTweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(Int16).FullName], typeof(SignedInt16Tweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(Int32).FullName], typeof(SignedInt32Tweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(Int64).FullName], typeof(SignedInt64Tweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(Byte).FullName], typeof(UnsignedByteTweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(UInt16).FullName], typeof(UnsignedInt16Tweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(UInt32).FullName], typeof(UnsignedInt32Tweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(UInt64).FullName], typeof(UnsignedInt64Tweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(Single).FullName], typeof(FloatTweener)); Assert.AreEqual(accessor._registeredPropertyTweeners[typeof(Double).FullName], typeof(DoubleTweener)); }
private void TestAllTweenedObjectsAreTicked(TweenSharkCore core) { var param0 = new PrivateObject(core); var accessor = new TweenSharkCore_Accessor(param0); accessor.Tick(); // all 3 tweened objects must still be there Assert.AreEqual(3, core.GetObjects().Count); Assert.AreEqual(3, core.GetObjectsTweenedObjects().Count); System.Threading.Thread.Sleep(1500); accessor.Tick(); // now the two fast tweens must be removed and only for are left Assert.AreEqual(2, core.GetObjects().Count); Assert.AreEqual(2, core.GetObjectsTweenedObjects().Count); System.Threading.Thread.Sleep(1500); accessor.Tick(); // now the two medium tweens must be removed and only for are left Assert.AreEqual(1, core.GetObjects().Count); Assert.AreEqual(1, core.GetObjectsTweenedObjects().Count); System.Threading.Thread.Sleep(2000); accessor.Tick(); // now all tweens must be removed and only for are left Assert.AreEqual(0, core.GetObjects().Count); Assert.AreEqual(0, core.GetObjectsTweenedObjects().Count); }
public void RegisterPropertyTweenerTest() { var ticker = new TweenSharkTickImpl(); var target = new TweenSharkCore(ticker); target.RegisterPropertyTweener(typeof(DoubleTweener), typeof(Double)); target.RegisterPropertyTweener(typeof(FloatTweener), typeof(Single)); var param0 = new PrivateObject(target); var accessor = new TweenSharkCore_Accessor(param0); Assert.AreEqual(2, accessor._registeredPropertyTweeners.Count); Assert.AreEqual(typeof(DoubleTweener), accessor._registeredPropertyTweeners[typeof(Double).FullName]); Assert.AreEqual(typeof(FloatTweener), accessor._registeredPropertyTweeners[typeof(Single).FullName]); }