Пример #1
0
        public void TildaShapeConstructorTest()
        {
            PowerPoint.Shape shape = new MockShape();
            int          id        = 0;
            TildaPicture target    = new TildaPicture((Microsoft.Office.Interop.PowerPoint.Shape)shape, id);

            Assert.AreEqual(shape, target.shape);
            Assert.AreEqual(Settings.Scaler(), target.scaler);
            Assert.AreEqual(0, target.id);
        }
Пример #2
0
        public void toRaphJSTest()
        {
            PowerPoint.Shape shape = new MockShape();
            int          id        = 0;
            TildaPicture target    = new TildaPicture(shape, id);

            TildaShape[] shapeMap = new TildaShape[2];
            shapeMap[0]              = target;
            shapeMap[0].shape.Width  = 20f;
            shapeMap[0].shape.Height = 40f;
            shapeMap[0].shape.Top    = 5f;
            shapeMap[0].shape.Left   = 6f;
            shapeMap[1]              = new TildaShape(new MockShape(), 1);
            shapeMap[1].shape.Width  = 50f;
            shapeMap[1].shape.Height = 60f;

            List <TildaAnimation> animationMap = new List <TildaAnimation>();

            TildaSlide slide    = new TildaSlide(new TildaTests.Mocks.MockSlide());
            string     expected = @"preso.shapes.push\(preso.paper.image\('assets/[0-9]*-[0-9]*-image.png',"
                                  + shapeMap[0].position() + "," + (shapeMap[0].shape.Width * Settings.Scaler()) + "," + shapeMap[0].shape.Height * Settings.Scaler() + @"\)\);";
            string actual;

            //Assert.AreEqual(slide.shapeCount, 0);
            actual = target.toRaphJS();

            Boolean doesEqual = Regex.IsMatch(actual, expected);

            Assert.AreEqual(true, doesEqual);

            //Adding animations
            TildaAnimation anim = new TildaAnimation(new MockEffect(), shapeMap[0]);

            anim.effect.Timing.Duration         = 5f;
            anim.effect.Timing.TriggerDelayTime = 15f;
            shapeMap[0].animations.Add(anim);

            expected = @"preso.shapes.push\(preso.paper.image\('assets/[0-9]*-[0-9]*-image.png',"
                       + shapeMap[0].position() + "," + (shapeMap[0].shape.Width * Settings.Scaler()) + "," + shapeMap[0].shape.Height * Settings.Scaler() + @"\)\);"
                       + @"preso.shapes\[\(preso.shapes.length-1\)\].attr\(\{'opacity':0\}\);preso.animations.push\(\{'ids':\[\(preso.shapes.length-1\)\],'dur':" + anim.effect.Timing.Duration * 1000
                       + @",'delay':" + anim.effect.Timing.TriggerDelayTime * 1000 + @",animate:\{'opacity':1\}\}\);";
            actual    = target.toRaphJS();
            doesEqual = Regex.IsMatch(actual, expected);
            Assert.AreEqual(true, doesEqual);
        }