public void TildaAudioConstructorTest() { PowerPoint.Shape shape = new TildaTests.Mocks.MockShape(); int id = 99; TildaAudio target = new TildaAudio(shape, id); Assert.AreEqual(id, target.id); Assert.AreEqual(shape, target.shape); }
public void exportAudioFile() { PowerPoint.Shape shape = new TildaTests.Mocks.MockShape(MsoShapeType.msoMedia); int id = 99; TildaAudio ta = new TildaAudio(shape, id); String actual = ta.toRaphJS(); Assert.AreEqual("", actual); }
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); }
public Shape AddTextbox(Microsoft.Office.Core.MsoTextOrientation Orientation, float Left, float Top, float Width, float Height) { MockShape shape = new MockShape(); shape.type = Microsoft.Office.Core.MsoShapeType.msoTextBox; shape.Left = Left; shape.Top = Top; shape.Width = Width; shape.Height = Height; shapes.Add(shape); return((Microsoft.Office.Interop.PowerPoint.Shape)shape); }
public void findYTest() { PowerPoint.Shape shape = new MockShape(); shape.Top = 50.3f; int id = 0; TildaShape target = new TildaShape(shape, id); double expected = shape.Top * Settings.Scaler(); double actual; actual = target.findY(); double difference = expected - actual; Assert.IsTrue(difference <= .00001); }
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); }
public Shape AddTextbox(Microsoft.Office.Core.MsoTextOrientation Orientation, float Left, float Top, float Width, float Height) { MockShape shape = new MockShape(); shape.type = Microsoft.Office.Core.MsoShapeType.msoTextBox; shape.Left = Left; shape.Top = Top; shape.Width = Width; shape.Height = Height; shapes.Add(shape); return (Microsoft.Office.Interop.PowerPoint.Shape)shape; }
private TildaTextbox singleLevelBulletsFixture() { PowerPoint.Shape shape = new MockShape(); int id = 15; Microsoft.Office.Core.TextRange2 tr = shape.TextFrame2.TextRange; // ` character is a level 1 bullet when the mock renders tr.Text = "`Bullet1~`Bullet2~`Bullet3"; shape.Left = 7f; shape.Width = 100f; shape.TextFrame2.MarginLeft = 1.1f; shape.TextFrame2.MarginRight = 1.2f; tr.Font.Name = "Verdana"; tr.Font.Size = 12f; tr.ParagraphFormat.SpaceBefore = 5.2f; tr.ParagraphFormat.SpaceAfter = 5.2f; int redRGB = 16711680; tr.Font.Fill.ForeColor.RGB = redRGB; shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft; shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorTop; return new TildaTextbox(shape, id); }
//TODO: animation test //some fixtures, these should prob end up in their own files. Not quite sure what to do with them in C# yet. private TildaTextbox oneSentenceFixture() { PowerPoint.Shape shape = new MockShape(); int id = 15; Microsoft.Office.Core.TextRange2 tr = shape.TextFrame2.TextRange; tr.Text = "Paragraph1"; shape.Left = 7f; shape.Width = 100f; shape.TextFrame2.MarginLeft = 1.1f; shape.TextFrame2.MarginRight = 1.2f; tr.Font.Name = "Verdana"; tr.Font.Size = 12f; tr.ParagraphFormat.SpaceBefore = 5.2f; int redRGB = 16711680; tr.Font.Fill.ForeColor.RGB = redRGB; shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft; shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorTop; return new TildaTextbox(shape, id); }
private TildaTextbox bulletsAndTextFixture(Microsoft.Office.Core.MsoNumberedBulletStyle style = Microsoft.Office.Core.MsoNumberedBulletStyle.msoBulletArabicPeriod) { PowerPoint.Shape shape = new MockShape(); int id = 15; Microsoft.Office.Core.TextRange2 tr = shape.TextFrame2.TextRange; // ` character is a level 1 bullet when the mock renders tr.Text = "some test here and such\rmore text here and such\rand more\r`Bullet1\r`Bullet2"; shape.Left = 7f; shape.Width = 100f; shape.TextFrame2.MarginLeft = 1.1f; shape.TextFrame2.MarginRight = 1.2f; tr.Font.Name = "Verdana"; tr.Font.Size = 12f; tr.ParagraphFormat.SpaceBefore = 5.2f; tr.ParagraphFormat.SpaceAfter = 5.2f; tr.ParagraphFormat.Bullet.Style = style; int redRGB = 16711680; tr.Font.Fill.ForeColor.RGB = redRGB; shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft; shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorTop; return new TildaTextbox(shape, id); }
public void TildaTextboxConstructorTest() { PowerPoint.Shape shape = new MockShape(); int id = 15; TildaTextbox target = new TildaTextbox(shape, id); Assert.AreEqual(shape,target.shape); Assert.AreEqual(id, target.id); }
public void fontStyleTest() { int redRGB = 16711680; string redHex = "#ff0000"; PowerPoint.Shape shape = new MockShape(); int id = 15; MockTextRange2 tr = (MockTextRange2)shape.TextFrame2.TextRange; tr.Font.Name = "Verdana"; tr.Font.Size = 12f; tr.Font.Fill.ForeColor.RGB = redRGB; TildaTextbox target = new TildaTextbox(shape, id); String expected = "'font-size':'" + Settings.Scaler() * tr.Font.Size + "','fill':'" + redHex + "'"; //No bold or italic Assert.AreEqual(expected + ",'font-family':'" + tr.Font.Name + "'", target.fontStyle()); //Italic only tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoCTrue; Assert.AreEqual(expected + ",'font-family':'" + tr.Font.Name + " italic'", target.fontStyle()); tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoTrue; Assert.AreEqual(expected + ",'font-family':'" + tr.Font.Name + " italic'", target.fontStyle()); //Bold only tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoFalse; tr.Font.Bold = Microsoft.Office.Core.MsoTriState.msoTrue; Assert.AreEqual(expected + ",'font-weight':'bold','font-family':'" + tr.Font.Name + "'", target.fontStyle()); tr.Font.Bold = Microsoft.Office.Core.MsoTriState.msoCTrue; Assert.AreEqual(expected + ",'font-weight':'bold','font-family':'" + tr.Font.Name + "'", target.fontStyle()); //Bold and Italic tr.Font.Italic = Microsoft.Office.Core.MsoTriState.msoCTrue; Assert.AreEqual(expected + ",'font-weight':'bold','font-family':'" + tr.Font.Name + " italic'", target.fontStyle()); }
public void fontPositionTest() { PowerPoint.Shape shape = new MockShape(); int id = 15; MockTextRange2 tr = (MockTextRange2)shape.TextFrame2.TextRange; TildaTextbox target = new TildaTextbox(shape, id); //left aligned shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft; Assert.AreEqual("'text-anchor': 'start'", target.fontPosition()); //center aligned shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignCenter; Assert.AreEqual("'text-anchor': 'middle'", target.fontPosition()); //right aligned shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignRight; Assert.AreEqual("'text-anchor': 'end'", target.fontPosition()); //otherwise don't care }
public void findYTest() { PowerPoint.Shape shape = new MockShape(); int id = 15; MockTextRange2 tr = (MockTextRange2)shape.TextFrame2.TextRange; shape.Top = 5f; shape.TextFrame2.MarginTop = 3.2f; shape.TextFrame2.MarginBottom = 4.2f; shape.Height = 100f; TildaTextbox target = new TildaTextbox(shape, id); //bottom aligned shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorBottom; Assert.AreEqual((shape.Top + shape.Height - shape.TextFrame2.MarginBottom) * Settings.Scaler(), target.findY(),.001); //baseline aligned shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorBottomBaseLine; Assert.AreEqual((shape.Top + shape.Height) * Settings.Scaler(), target.findY(), .001); //top aligned shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorTop; Assert.AreEqual((shape.Top + shape.TextFrame2.MarginTop) * Settings.Scaler(), target.findY(), .001); //top baseline aligned shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorTopBaseline; Assert.AreEqual((shape.Top) * Settings.Scaler(), target.findY(), .001); //middle shape.TextFrame2.VerticalAnchor = Microsoft.Office.Core.MsoVerticalAnchor.msoAnchorMiddle; Assert.AreEqual((shape.Height / 2 + shape.TextFrame2.MarginTop + shape.Top) * Settings.Scaler(), target.findY(), .001); //otherwise don't care! }
public void findXTest() { PowerPoint.Shape shape = new MockShape(); int id = 15; MockTextRange2 tr = (MockTextRange2)shape.TextFrame2.TextRange; shape.Left = 7f; shape.Width = 100f; shape.TextFrame2.MarginLeft = 1.1f; shape.TextFrame2.MarginRight = 1.2f; TildaTextbox target = new TildaTextbox(shape, id); //left aligned shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignLeft; Assert.AreEqual((shape.Left + shape.TextFrame2.MarginLeft) * Settings.Scaler(), target.findX(), .001); //right aligned shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignRight; Assert.AreEqual((shape.Left + shape.Width - shape.TextFrame2.MarginRight) * Settings.Scaler(), target.findX(), .001); //centered shape.TextFrame2.TextRange.ParagraphFormat.Alignment = Microsoft.Office.Core.MsoParagraphAlignment.msoAlignCenter; Assert.AreEqual((shape.Width / 2 + shape.Left + shape.TextFrame2.MarginLeft) * Settings.Scaler(), target.findX(), .001); //dont care otherwise }
public void positionTest() { PowerPoint.Shape shape = new MockShape(); shape.Left = 30f; shape.Top = 55f; int id = 5; TildaShape target = new TildaShape(shape, id); string expected = (double)(shape.Left * Settings.Scaler()) + "," + (double)(shape.Top * Settings.Scaler()); string actual; actual = target.position(); Assert.AreEqual(expected, actual); }
public void RotationTest() { //create Shape PowerPoint.Shape shape = new MockShape(); shape.Rotation = 90; //set attributes //compare String expected = "'transformation':'r90'"; TildaShape target = new TildaShape(shape); String actual = target.transformation(); Assert.AreEqual(expected, actual); }
public void TildaShapeConstructorTest() { PowerPoint.Shape shape = new MockShape(); TildaShape target = new TildaShape(shape,0); Assert.AreEqual(shape, target.shape); Assert.AreEqual(Settings.Scaler(), target.scaler); Assert.AreEqual(0, target.id); }
public void toRaphJSTest() { PowerPoint.Shape shape = new MockShape(); int id = 0; TildaShape target = new TildaShape(shape, id); string expected = string.Empty; string actual; actual = target.toRaphJS(); Assert.AreEqual(expected, actual); }