public PresentationFixture() { Pre001 = SCPresentation.Open(Properties.Resources._001, false); Pre002 = SCPresentation.Open(Properties.Resources._002, false); Pre003 = SCPresentation.Open(Properties.Resources._003, false); Pre004 = SCPresentation.Open(Properties.Resources._004, false); Pre006 = SCPresentation.Open(Properties.Resources._006_1_slides, false); Pre008 = SCPresentation.Open(Properties.Resources._008, false); Pre009 = SCPresentation.Open(Properties.Resources._009, false); Pre010 = SCPresentation.Open(Properties.Resources._010, false); Pre011 = SCPresentation.Open(Properties.Resources._011_dt, false); Pre012 = SCPresentation.Open(Properties.Resources._012_title_placeholder, false); Pre013 = SCPresentation.Open(Properties.Resources._013, false); Pre014 = SCPresentation.Open(Properties.Resources._014, false); Pre015 = SCPresentation.Open(Properties.Resources._015, false); Pre016 = SCPresentation.Open(Properties.Resources._016, false); Pre017 = SCPresentation.Open(Properties.Resources._017, false); Pre018 = SCPresentation.Open(Properties.Resources._018, false); Pre019 = SCPresentation.Open(Properties.Resources._019, false); Pre020 = SCPresentation.Open(Properties.Resources._020, false); Pre021 = SCPresentation.Open(Properties.Resources._021, false); Pre024 = SCPresentation.Open(Properties.Resources._024, false); Pre025 = SCPresentation.Open(Properties.Resources._025, false); Pre026 = SCPresentation.Open(Properties.Resources._026, false); Pre028 = SCPresentation.Open(Properties.Resources._028, false); Pre029 = SCPresentation.Open(Properties.Resources._029, false); Pre030 = SCPresentation.Open(Properties.Resources._030, false); Pre031 = SCPresentation.Open(Properties.Resources._031, false); Pre032 = SCPresentation.Open(Properties.Resources._032, false); Pre033 = SCPresentation.Open(Properties.Resources._033, false); Pre034 = SCPresentation.Open(Properties.Resources._034, false); Pre035 = SCPresentation.Open(Properties.Resources._035, false); Pre036 = SCPresentation.Open(Properties.Resources._036, false); Pre037 = SCPresentation.Open(Properties.Resources._037, false); }
public static IParagraph GetParagraph(SCPresentation presentation, SlideElementQuery paragraphRequest) { IAutoShape autoShape = presentation.Slides[paragraphRequest.SlideIndex] .Shapes.First(sp => sp.Id == paragraphRequest.ShapeId) as IAutoShape; return(autoShape.TextBox.Paragraphs[paragraphRequest.ParagraphIndex]); }
public static IEnumerable <object[]> TestCasesShapesCount() { SCPresentation presentation = SCPresentation.Open(Properties.Resources._009, false); ISlide slide = presentation.Slides[0]; yield return(new object[] { slide, 6 }); slide = presentation.Slides[1]; yield return(new object[] { slide, 6 }); slide = SCPresentation.Open(Properties.Resources._002, false).Slides[0]; yield return(new object[] { slide, 4 }); slide = SCPresentation.Open(Properties.Resources._003, false).Slides[0]; yield return(new object[] { slide, 5 }); slide = SCPresentation.Open(Properties.Resources._013, false).Slides[0]; yield return(new object[] { slide, 4 }); slide = SCPresentation.Open(Properties.Resources._023, false).Slides[0]; yield return(new object[] { slide, 1 }); slide = SCPresentation.Open(Properties.Resources._014, false).Slides[2]; yield return(new object[] { slide, 5 }); }
public static IEnumerable <object[]> TestCasesIsBold() { SCPresentation presentationCase1 = SCPresentation.Open(Resources._020, true); SlideElementQuery portionRequestCase1 = new(); portionRequestCase1.SlideIndex = 2; portionRequestCase1.ShapeId = 7; portionRequestCase1.ParagraphIndex = 0; portionRequestCase1.PortionIndex = 0; SCPresentation presentationCase2 = SCPresentation.Open(Resources._026, true); SlideElementQuery portionRequestCase2 = new(); portionRequestCase2.SlideIndex = 0; portionRequestCase2.ShapeId = 128; portionRequestCase2.ParagraphIndex = 0; portionRequestCase2.PortionIndex = 0; var testCases = new List <object[]> { new object[] { presentationCase1, portionRequestCase1 }, new object[] { presentationCase2, portionRequestCase2 } }; return(testCases); }
private static IPortion GetPortion(SCPresentation presentation) { IAutoShape autoShape = presentation.Slides[0].Shapes.First(sp => sp.Id == 4) as IAutoShape; IPortion portion = autoShape.TextBox.Paragraphs[0].Portions[0]; return(portion); }
public static IParagraph GetParagraph(MemoryStream presentationStream, SlideElementQuery paragraphRequest) { SCPresentation presentation = SCPresentation.Open(presentationStream, false); IAutoShape autoShape = presentation.Slides[paragraphRequest.SlideIndex] .Shapes.First(sp => sp.Id == paragraphRequest.ShapeId) as IAutoShape; return(autoShape.TextBox.Paragraphs[paragraphRequest.ParagraphIndex]); }
public void Open_ThrowsPresentationIsLargeException_WhenThePresentationContentSizeIsBeyondThePermitted() { // Arrange var bytes = new byte[Limitations.MaxPresentationSize + 1]; // Act Action act = () => SCPresentation.Open(bytes, false); // Assert act.Should().Throw <PresentationIsLargeException>(); }
public static IEnumerable <object[]> GeometryTypeTestCases() { var pre021 = SCPresentation.Open(Resources._021, false); var shapes = pre021.Slides[3].Shapes; var shapeCase1 = shapes.First(sp => sp.Id == 2); var shapeCase2 = shapes.First(sp => sp.Id == 3); yield return(new object[] { shapeCase1, GeometryType.Rectangle }); yield return(new object[] { shapeCase2, GeometryType.Ellipse }); }
public void SlideMasterShapesCount_ReturnsNumberOfShapesOnTheMasterSlide() { // Arrange SCPresentation presentation = _fixture.Pre001; // Act int slideMasterShapesCount = presentation.SlideMasters[0].Shapes.Count; // Assert slideMasterShapesCount.Should().Be(7); }
public void Hide_MethodHidesSlide_WhenItIsExecuted() { // Arrange var pre = SCPresentation.Open(Properties.Resources._001, true); var slide = pre.Slides.First(); // Act slide.Hide(); // Assert slide.Hidden.Should().Be(true); }
internal static SlideMasterCollection Create(SCPresentation presentation) { IEnumerable <SlideMasterPart> slideMasterParts = presentation.PresentationPart.SlideMasterParts; var slideMasters = new List <SCSlideMaster>(slideMasterParts.Count()); foreach (SlideMasterPart slideMasterPart in slideMasterParts) { slideMasters.Add(new SCSlideMaster(presentation, slideMasterPart.SlideMaster)); } return(new SlideMasterCollection(presentation, slideMasters)); }
public static IEnumerable <object[]> TestCasesCellIsMergedCell() { ITable table = (ITable)SCPresentation.Open(Resources._001, false).Slides[1].Shapes.First(sp => sp.Id == 3); yield return(new object[] { table[0, 0], table[1, 0] }); table = (ITable)SCPresentation.Open(Resources._001, false).Slides[1].Shapes.First(sp => sp.Id == 5); yield return(new object[] { table[1, 1], table[2, 1] }); table = (ITable)SCPresentation.Open(Resources._001, false).Slides[3].Shapes.First(sp => sp.Id == 4); yield return(new object[] { table[0, 1], table[1, 1] }); }
public void Name_SetterThrowsException_WhenAnUserTryChangeFontNameForPortionOfAPlaceholderShape() { // Arrange IAutoShape autoShape = (IAutoShape)SCPresentation.Open(Resources._001, true).Slides[2].Shapes .First(sp => sp.Id == 4); IPortion paragraphPortion = autoShape.TextBox.Paragraphs[0].Portions[0]; // Act Action action = () => paragraphPortion.Font.Name = "Time New Roman"; // Assert action.Should().Throw <PlaceholderCannotBeChangedException>(); }
public void ParagraphTextSetter_ThrowsException_WhenParagraphWasRemoved() { IPresentation presentation = SCPresentation.Open(Properties.Resources._020, true); IAutoShape autoShape = (IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 8); ITextBox textBox = autoShape.TextBox; IParagraph paragraph = textBox.Paragraphs.First(); textBox.Text = "new box content"; // Act-Assert paragraph.Invoking(p => p.Text = "new paragraph text") .Should().Throw <ElementIsRemovedException>("because paragraph was being removed while changing box content."); }
public void SlideWidthAndSlideHeight_ReturnWidthAndHeightSizesOfThePresentationSlides() { // Arrange SCPresentation presentation = _fixture.Pre009; // Act int slideWidth = presentation.SlideWidth; int slideHeight = presentation.SlideHeight; // Assert slideWidth.Should().Be(9144000); slideHeight.Should().Be(5143500); }
public void Text_SetterThrowsElementIsRemovedException_WhenPortionIsRemoved() { // Arrange IPresentation presentation = SCPresentation.Open(Resources._001, true); IAutoShape autoShape = (IAutoShape)presentation.Slides[0].Shapes.First(sp => sp.Id == 5); IPortionCollection portions = autoShape.TextBox.Paragraphs[0].Portions; IPortion portion = portions[0]; portions.Remove(portion); // Act-Assert portion.Invoking(p => p.Text = "new text").Should().Throw <ElementIsRemovedException>(); }
public void Name_SetterChangesFontName() { // Arrange const string newFont = "Time New Roman"; IAutoShape autoShape = SCPresentation.Open(Resources._001, true).Slides[0].Shapes.First(sp => sp.Id == 4) as IAutoShape; IPortion paragraphPortion = autoShape.TextBox.Paragraphs[0].Portions[0]; // Act paragraphPortion.Font.Name = newFont; // Assert paragraphPortion.Font.Name.Should().BeEquivalentTo(newFont); }
public void SlideMastersCount_ReturnsNumberOfMasterSlidesInThePresentation() { // Arrange SCPresentation presentationCase1 = _fixture.Pre001; SCPresentation presentationCase2 = _fixture.Pre002; // Act int slideMastersCountCase1 = presentationCase1.SlideMasters.Count; int slideMastersCountCase2 = presentationCase2.SlideMasters.Count; // Assert slideMastersCountCase1.Should().Be(1); slideMastersCountCase2.Should().Be(2); }
public static IEnumerable <object[]> TestCasesPlaceholderType() { IShape shape = SCPresentation.Open(Resources._021, false).Slides[3].Shapes.First(sp => sp.Id == 2); yield return(new object[] { shape, PlaceholderType.Footer }); shape = SCPresentation.Open(Resources._008, false).Slides[0].Shapes.First(sp => sp.Id == 3); yield return(new object[] { shape, PlaceholderType.DateAndTime }); shape = SCPresentation.Open(Resources._019, false).Slides[0].Shapes.First(sp => sp.Id == 2); yield return(new object[] { shape, PlaceholderType.SlideNumber }); shape = SCPresentation.Open(Resources._013, false).Slides[0].Shapes.First(sp => sp.Id == 281); yield return(new object[] { shape, PlaceholderType.Custom }); }
public void ParagraphsAdd_AddsANewTextParagraphAtTheEndOfTheTextBoxAndReturnsAddedParagraph_WhenParagraphIsAddedAfterTextBoxContentChanged() { IPresentation presentation = SCPresentation.Open(Properties.Resources._001, true); IAutoShape autoShape = (IAutoShape)presentation.Slides[0].Shapes.First(sp => sp.Id == 3); ITextBox textBox = autoShape.TextBox; IParagraphCollection paragraphs = textBox.Paragraphs; IParagraph paragraph = textBox.Paragraphs.First(); textBox.Text = "A new text"; // Act IParagraph newParagraph = paragraphs.Add(); // Assert newParagraph.Should().NotBeNull(); }
public void MergeCells_Merges0x1And0x2CellsOf3x2Table() { // Arrange IPresentation presentation = SCPresentation.Open(Resources._001, true); ITable table = (ITable)presentation.Slides[2].Shapes.First(sp => sp.Id == 3); var mStream = new MemoryStream(); // Act table.MergeCells(table[0, 1], table[0, 2]); // Assert AssertTable(table); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); table = (ITable)presentation.Slides[2].Shapes.First(sp => sp.Id == 3); AssertTable(table);
public async void AutoShapeFillPictureSetImage_ChangeFilledPictureImage() { // Arrange SCPresentation presentation = SCPresentation.Open(Resources._009, true); IAutoShape autoShape = (IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 4); var newImage = new MemoryStream(Resources.test_image_2); var imageSizeBefore = (await autoShape.Fill.Picture.GetImageBytes().ConfigureAwait(false)).Length; // Act autoShape.Fill.Picture.SetImage(newImage); // Assert var imageSizeAfter = (await autoShape.Fill.Picture.GetImageBytes().ConfigureAwait(false)).Length; imageSizeAfter.Should().NotBe(imageSizeBefore); }
public async void ImageExSetImage_MethodSetsShapeImage_WhenCustomImageStreamIsPassed() { // Arrange var customImageStream = new MemoryStream(Properties.Resources.test_image_2); IPicture picture = (IPicture)SCPresentation.Open(Properties.Resources._009, true).Slides[1].Shapes .First(sp => sp.Id == 3); var originLength = (await picture.Image.GetImageBytes().ConfigureAwait(false)).Length; // Act picture.Image.SetImage(customImageStream); // Assert var editedLength = (await picture.Image.GetImageBytes().ConfigureAwait(false)).Length; editedLength.Should().NotBe(originLength); }
public void SlidesRemove_RemovesFirstSlideFromPresentation_WhenFirstSlideObjectWasPassed(byte[] pptxBytes, int expectedSlidesCount) { // Arrange SCPresentation presentation = SCPresentation.Open(pptxBytes, true); ISlide removingSlide = presentation.Slides[0]; var mStream = new MemoryStream(); // Act presentation.Slides.Remove(removingSlide); // Assert presentation.Slides.Should().HaveCount(expectedSlidesCount); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); presentation.Slides.Should().HaveCount(expectedSlidesCount); }
public async void BackgroundSetImage_ChangesBackground_WhenImageStreamIsPassed() { // Arrange var pre = SCPresentation.Open(Properties.Resources._009, true); var backgroundImage = pre.Slides[0].Background; var imgStream = new MemoryStream(Properties.Resources.test_image_2); var bytesBefore = await backgroundImage.GetImageBytes().ConfigureAwait(false); // Act backgroundImage.SetImage(imgStream); backgroundImage.SetImage(imgStream); // Assert var bytesAfter = await backgroundImage.GetImageBytes().ConfigureAwait(false); bytesAfter.Length.Should().NotBe(bytesBefore.Length); }
public void IsBold_Setter_AddsBoldForPlaceholderTextFont(SCPresentation presentation, SlideElementQuery portionRequest) { // Arrange MemoryStream mStream = new (); IPortion portion = TestHelper.GetParagraphPortion(presentation, portionRequest); // Act portion.Font.IsBold = true; // Assert portion.Font.IsBold.Should().BeTrue(); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); portion = TestHelper.GetParagraphPortion(presentation, portionRequest); portion.Font.IsBold.Should().BeTrue(); }
public void CustomData_ReturnsCustomDataOfTheShape_WhenShapeWasAssignedSomeCustomData() { // Arrange const string customDataString = "Test custom data"; var savedPreStream = new MemoryStream(); var presentation = SCPresentation.Open(Resources._009, true); var shape = presentation.Slides.First().Shapes.First(); // Act shape.CustomData = customDataString; presentation.SaveAs(savedPreStream); // Assert presentation = SCPresentation.Open(savedPreStream, false); shape = presentation.Slides.First().Shapes.First(); shape.CustomData.Should().Be(customDataString); }
public void CategoryName_SetterChangeName_OfMainCategoryInMultiLevelCategoryBarChart() { // Arrange IPresentation presentation = SCPresentation.Open(Resources._025, true); MemoryStream mStream = new(); IChart barChart2 = (IChart)_fixture.Pre025.Slides[0].Shapes.First(sp => sp.Id == 4); const string newMainCategoryName = "Clothing_new"; // Act barChart2.Categories[0].MainCategory.Name = newMainCategoryName; // Assert barChart2.Categories[0].Name.Should().Be(newMainCategoryName); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); barChart2 = (IChart)presentation.Slides[0].Shapes.First(sp => sp.Id == 4); barChart2.Categories[0].Name.Should().Be(newMainCategoryName); }
public void CategoryName_SetterChangeName_OfCategoryInPieChart() { // Arrange IPresentation presentation = SCPresentation.Open(Resources._025, true); MemoryStream mStream = new(); IChart pieChart4 = (IChart)presentation.Slides[0].Shapes.First(sp => sp.Id == 7); const string newCategoryName = "Category 1_new"; // Act pieChart4.Categories[0].Name = newCategoryName; // Assert pieChart4.Categories[0].Name.Should().Be(newCategoryName); presentation.SaveAs(mStream); presentation = SCPresentation.Open(mStream, false); pieChart4 = (IChart)presentation.Slides[0].Shapes.First(sp => sp.Id == 7); pieChart4.Categories[0].Name.Should().Be(newCategoryName); }
public void RowRemoveAt_RemovesTableRowWithSpecifiedIndex() { // Arrange IPresentation presentation = SCPresentation.Open(Resources._009, true); ITable table = (ITable)presentation.Slides[2].Shapes.First(sp => sp.Id == 3); int originRowsCount = table.Rows.Count; var mStream = new MemoryStream(); // Act table.Rows.RemoveAt(0); // Assert table.Rows.Should().HaveCountLessThan(originRowsCount); presentation.SaveAs(mStream); table = (ITable)SCPresentation.Open(mStream, false).Slides[2].Shapes.First(sp => sp.Id == 3); table.Rows.Should().HaveCountLessThan(originRowsCount); }