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]);
        }
        private TweenSharkCore SetupCoreWithTweens()
        {
            var core = new TweenSharkCore(new TweenSharkTickImpl());

            core.RegisterPropertyTweener(typeof(DoubleTweener), typeof(Double));
            core.RegisterPropertyTweener(typeof(FloatTweener), typeof(Single));

            // short tweens (one second)
            var duration = 1;
            var to       = new TweeningTestObject {
                DoubleValue = 100, FloatValue = 100
            };
            var tween = new TweenShark(to, duration, new TweenOps().PropTo("DoubleValue", 200));

            core.To(tween);
            tween = new TweenShark(to, duration, new TweenOps().PropTo("FloatValue", 200));
            core.To(tween);

            // medium duration tweens (3 seconds)
            duration = 3;
            to       = new TweeningTestObject {
                DoubleValue = 100
            };
            tween = new TweenShark(to, duration, new TweenOps().PropTo("DoubleValue", 200));
            core.To(tween);
            tween = new TweenShark(to, duration, new TweenOps().PropTo("FloatValue", 200));
            core.To(tween);

            // medium duration tweens (5 seconds)
            duration = 5;
            to       = new TweeningTestObject {
                DoubleValue = 100
            };
            tween = new TweenShark(to, duration, new TweenOps().PropTo("DoubleValue", 200));
            core.To(tween);
            tween = new TweenShark(to, duration, new TweenOps().PropTo("FloatValue", 200));
            core.To(tween);

            return(core);
        }
Exemple #4
0
        public static void Initialize(ITweenSharkTick ticker, ILogger logger)
        {
            Logger = logger;

            if (_core == null)
            {
                _core = new TweenSharkCore(ticker);
                // register tweener for ints
                RegisterPropertyTweener(typeof(SignedByteTweener), typeof(SByte));
                RegisterPropertyTweener(typeof(SignedInt16Tweener), typeof(Int16));
                RegisterPropertyTweener(typeof(SignedInt32Tweener), typeof(Int32));
                RegisterPropertyTweener(typeof(SignedInt64Tweener), typeof(Int64));
                // register tweener for unsigned ints
                RegisterPropertyTweener(typeof(UnsignedByteTweener), typeof(Byte));
                RegisterPropertyTweener(typeof(UnsignedInt16Tweener), typeof(UInt16));
                RegisterPropertyTweener(typeof(UnsignedInt32Tweener), typeof(UInt32));
                RegisterPropertyTweener(typeof(UnsignedInt64Tweener), typeof(UInt64));
                // register tweener for floats
                RegisterPropertyTweener(typeof(FloatTweener), typeof(Single));
                // register tweener for doubles
                RegisterPropertyTweener(typeof(DoubleTweener), typeof(Double));
            }
        }
 public void TweenSharkCoreConstructorTest()
 {
     var ticker = new TweenSharkTickImpl();
     var target = new TweenSharkCore(ticker);
 }