예제 #1
0
        public void CreateTweenerWithAccessorTest()
        {
            var obj = new TweeningTestObject();
            var registeredPropertyTweens = new Dictionary <string, Type>();

            // register tweener for ints
            registeredPropertyTweens.Add(typeof(SByte).FullName, typeof(SignedByteTweener));
            registeredPropertyTweens.Add(typeof(Int16).FullName, typeof(SignedInt16Tweener));
            registeredPropertyTweens.Add(typeof(Int32).FullName, typeof(SignedInt32Tweener));
            registeredPropertyTweens.Add(typeof(Int64).FullName, typeof(SignedInt64Tweener));
            // register tweener for unsigned ints
            registeredPropertyTweens.Add(typeof(Byte).FullName, typeof(UnsignedByteTweener));
            registeredPropertyTweens.Add(typeof(UInt16).FullName, typeof(UnsignedInt16Tweener));
            registeredPropertyTweens.Add(typeof(UInt32).FullName, typeof(UnsignedInt32Tweener));
            registeredPropertyTweens.Add(typeof(UInt64).FullName, typeof(UnsignedInt64Tweener));
            // register tweener for floats
            registeredPropertyTweens.Add(typeof(Single).FullName, typeof(FloatTweener));
            // register tweener for doubles
            registeredPropertyTweens.Add(typeof(Double).FullName, typeof(DoubleTweener));


            var param0 = new PrivateObject(new TweenedObject(new TweeningTestObject(), registeredPropertyTweens));
            var target = new TweenedObject_Accessor(param0);

            ITweenSharkTweener tweener = target.CreateTweener(new PropertyOps("SbyteValue", 100, false));

            Assert.IsInstanceOfType(tweener, typeof(SignedByteTweener));

            tweener = target.CreateTweener(new PropertyOps("ShortValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(SignedInt16Tweener));

            tweener = target.CreateTweener(new PropertyOps("IntValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(SignedInt32Tweener));

            tweener = target.CreateTweener(new PropertyOps("LongValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(SignedInt64Tweener));

            tweener = target.CreateTweener(new PropertyOps("ByteValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(UnsignedByteTweener));

            tweener = target.CreateTweener(new PropertyOps("UshortValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(UnsignedInt16Tweener));

            tweener = target.CreateTweener(new PropertyOps("UintValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(UnsignedInt32Tweener));

            tweener = target.CreateTweener(new PropertyOps("UlongValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(UnsignedInt64Tweener));

            tweener = target.CreateTweener(new PropertyOps("DoubleValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(DoubleTweener));

            tweener = target.CreateTweener(new PropertyOps("FloatValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(FloatTweener));
        }
예제 #2
0
        public void AddTweenSharkTest()
        {
            Assert.Inconclusive("needs to be rewritten to prevent runtime errors");

            var obj = new TweeningTestObject();
            var registeredPropertyTweens = new Dictionary <string, Type>();

            registeredPropertyTweens.Add(typeof(SByte).FullName, typeof(SignedByteTweener));

            var target   = new TweenedObject(obj, registeredPropertyTweens);
            var param0   = new PrivateObject(target);
            var accessor = new TweenedObject_Accessor(param0);

            var tweenShark = new TweenShark(obj, 1, new TweenOps().PropTo("DoubleValue", 100).PropTo("FloatValue", 101));

            target.AddTweenShark(tweenShark);


            // check for count of tweens and tweened properties
            Assert.AreEqual(1, accessor._tweens.Count);
            Assert.AreEqual(2, accessor._propertyTweens.Count);
            // check for target values
            Assert.AreEqual(100, ((DoubleTweener)(accessor._propertyTweens["DoubleValue"])).GetTargetValue());
            Assert.AreEqual(101, ((FloatTweener)(accessor._propertyTweens["FloatValue"])).GetTargetValue());

            // when adding a tween on another object the number of tweens must not change, because we do not add the tween
            tweenShark = new TweenShark(new TweeningTestObject(), 1, new TweenOps());
            target.AddTweenShark(tweenShark);
            // check for count of tweens and tweened properties
            Assert.AreEqual(1, accessor._tweens.Count);
            Assert.AreEqual(2, accessor._propertyTweens.Count);

            // when adding a tween on the correct object but with another property the numbers must change
            tweenShark = new TweenShark(obj, 1, new TweenOps().PropTo("IntValue", 102));
            target.AddTweenShark(tweenShark);
            // check for count of tweens and tweened properties
            Assert.AreEqual(2, accessor._tweens.Count);
            Assert.AreEqual(3, accessor._propertyTweens.Count);
            // check for target values
            Assert.AreEqual(100, ((DoubleTweener)(accessor._propertyTweens["DoubleValue"])).GetTargetValue());
            Assert.AreEqual(101, ((FloatTweener)(accessor._propertyTweens["FloatValue"])).GetTargetValue());
            Assert.AreEqual(102, ((SignedInt32Tweener)(accessor._propertyTweens["IntValue"])).GetTargetValue());

            // but when we now add another tween that overrides tweened properties, only the number of tweens may change
            tweenShark = new TweenShark(obj, 1, new TweenOps().PropTo("DoubleValue", 200).PropTo("FloatValue", 201).PropTo("IntValue", 202));
            target.AddTweenShark(tweenShark);
            // check for count of tweens and tweened properties
            Assert.AreEqual(3, accessor._tweens.Count);
            Assert.AreEqual(3, accessor._propertyTweens.Count);
            // check for target values
            Assert.AreEqual(200, ((DoubleTweener)(accessor._propertyTweens["DoubleValue"])).GetTargetValue());
            Assert.AreEqual(201, ((FloatTweener)(accessor._propertyTweens["FloatValue"])).GetTargetValue());
            Assert.AreEqual(202, ((SignedInt32Tweener)(accessor._propertyTweens["IntValue"])).GetTargetValue());
        }
예제 #3
0
        public void CreateTweenerTest()
        {
            var obj = new TweeningTestObject();
            var registeredPropertyTweens = new Dictionary <string, Type>();

            registeredPropertyTweens.Add(typeof(SByte).FullName, typeof(SignedByteTweener));

            var param0 = new PrivateObject(new TweenedObject(new TweeningTestObject(), registeredPropertyTweens));
            var target = new TweenedObject_Accessor(param0);

            // when we give a tweener we must get one returned
            ITweenSharkTweener tweener = target.CreateTweener(new PropertyOps("SbyteValue", 100, new GenericTweenerImpl <SByte>(), false));

            Assert.IsInstanceOfType(tweener, typeof(GenericTweenerImpl <SByte>));

            // when we dont give a tweener CreateTweener will try to create it
            tweener = target.CreateTweener(new PropertyOps("SbyteValue", 100, false));
            Assert.IsInstanceOfType(tweener, typeof(SignedByteTweener));
        }