Exemplo n.º 1
0
        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);
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        public void IsItalic_Setter_SetsItalicFontForForNonPlaceholderText()
        {
            // Arrange
            var           mStream                 = new MemoryStream();
            IPresentation presentation            = SCPresentation.Open(Resources._020, true);
            IAutoShape    nonPlaceholderAutoShape = (IAutoShape)presentation.Slides[0].Shapes.First(sp => sp.Id == 2);
            IPortion      portion                 = nonPlaceholderAutoShape.TextBox.Paragraphs[0].Portions[0];

            // Act
            portion.Font.IsItalic = true;

            // Assert
            portion.Font.IsItalic.Should().BeTrue();
            presentation.SaveAs(mStream);
            presentation            = SCPresentation.Open(mStream, false);
            nonPlaceholderAutoShape = (IAutoShape)presentation.Slides[0].Shapes.First(sp => sp.Id == 2);
            portion = nonPlaceholderAutoShape.TextBox.Paragraphs[0].Portions[0];
            portion.Font.IsItalic.Should().BeTrue();
        }
Exemplo n.º 6
0
        public void ColumnWidthSetter_ChangeTableColumnWidth()
        {
            // Arrange
            IPresentation presentation   = SCPresentation.Open(Resources._001, true);
            ITable        table          = (ITable)presentation.Slides[1].Shapes.First(sp => sp.Id == 3);
            const long    newColumnWidth = 4074000;
            var           mStream        = new MemoryStream();

            // Act
            table.Columns[0].Width = newColumnWidth;

            // Assert
            table.Columns[0].Width.Should().Be(newColumnWidth);

            presentation.SaveAs(mStream);
            presentation = SCPresentation.Open(mStream, false);
            table        = (ITable)presentation.Slides[1].Shapes.First(sp => sp.Id == 3);
            table.Columns[0].Width.Should().Be(newColumnWidth);
        }
        public void SlidesAdd_AddsSpecifiedSlideAtTheEndOfTheSlideCollection()
        {
            // Arrange
            ISlide        sourceSlide         = _fixture.Pre001.Slides[0];
            IPresentation destPre             = SCPresentation.Open(Properties.Resources._002, true);
            int           originSlidesCount   = destPre.Slides.Count;
            int           expectedSlidesCount = originSlidesCount + 1;
            MemoryStream  savedPre            = new ();

            // Act
            destPre.Slides.Add(sourceSlide);

            // Assert
            destPre.Slides.Count.Should().Be(expectedSlidesCount, "because the new slide has been added");

            destPre.SaveAs(savedPre);
            destPre = SCPresentation.Open(savedPre, false);
            destPre.Slides.Count.Should().Be(expectedSlidesCount, "because the new slide has been added");
        }
Exemplo n.º 8
0
        public void IsItalic_SetterSetsNonItalicFontForPlaceholderText_WhenFalseValueIsPassed()
        {
            // Arrange
            var           mStream              = new MemoryStream();
            IPresentation presentation         = SCPresentation.Open(Resources._020, true);
            IAutoShape    placeholderAutoShape = (IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 7);
            IPortion      portion              = placeholderAutoShape.TextBox.Paragraphs[0].Portions[0];

            // Act
            portion.Font.IsItalic = false;

            // Assert
            portion.Font.IsItalic.Should().BeFalse();
            presentation.SaveAs(mStream);

            presentation         = SCPresentation.Open(mStream, false);
            placeholderAutoShape = (IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 7);
            portion = placeholderAutoShape.TextBox.Paragraphs[0].Portions[0];
            portion.Font.IsItalic.Should().BeFalse();
        }
Exemplo n.º 9
0
        public void MergeCells_MergesSpecifiedCellsRange(int rowIdx1, int colIdx1, int rowIdx2, int colIdx2)
        {
            // Arrange
            IPresentation presentation = SCPresentation.Open(Resources._001, true);
            ITable        table        = (ITable)presentation.Slides[1].Shapes.First(sp => sp.Id == 4);
            var           mStream      = new MemoryStream();

            // Act
            table.MergeCells(table[rowIdx1, colIdx1], table[rowIdx2, colIdx2]);

            // Assert
            table[rowIdx1, colIdx1].IsMergedCell.Should().BeTrue();
            table[rowIdx2, colIdx2].IsMergedCell.Should().BeTrue();

            presentation.SaveAs(mStream);
            presentation = SCPresentation.Open(mStream, false);
            table        = (ITable)presentation.Slides[1].Shapes.First(sp => sp.Id == 4);
            table[rowIdx1, colIdx1].IsMergedCell.Should().BeTrue();
            table[rowIdx2, colIdx2].IsMergedCell.Should().BeTrue();
        }
Exemplo n.º 10
0
        public void MergeCells_Merges0x0And0x1CellsOf2x2Table()
        {
            // Arrange
            IPresentation presentation = SCPresentation.Open(Resources._001, true);
            ITable        table        = (ITable)presentation.Slides[2].Shapes.First(sp => sp.Id == 5);
            var           mStream      = new MemoryStream();

            // Act
            table.MergeCells(table[0, 0], table[0, 1]);

            // Assert
            table[0, 0].IsMergedCell.Should().BeTrue();
            table[0, 1].IsMergedCell.Should().BeTrue();
            table[0, 0].TextBox.Text.Should().Be($"id5{Environment.NewLine}Text0_1");

            presentation.SaveAs(mStream);
            presentation = SCPresentation.Open(mStream, false);
            table        = (ITable)presentation.Slides[2].Shapes.First(sp => sp.Id == 5);
            table[0, 0].IsMergedCell.Should().BeTrue();
            table[0, 1].IsMergedCell.Should().BeTrue();
            table[0, 0].TextBox.Text.Should().Be($"id5{Environment.NewLine}Text0_1");
        }
Exemplo n.º 11
0
        public void Text_SetterChangesTextBoxContent_WhenTheFirstParagraphIsEmpty()
        {
            // Arrange
            IPresentation presentation = SCPresentation.Open(Resources._020, true);
            ITextBox      textBox      = ((IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 8)).TextBox;
            const string  newText      = "Test";
            var           mStream      = new MemoryStream();

            // Act
            textBox.Text = newText;

            // Assert
            textBox.Text.Should().BeEquivalentTo(newText);
            textBox.Paragraphs.Should().HaveCount(1);

            presentation.SaveAs(mStream);
            presentation.Close();
            presentation = SCPresentation.Open(mStream, false);
            textBox      = ((IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 8)).TextBox;
            textBox.Text.Should().BeEquivalentTo(newText);
            textBox.Paragraphs.Should().HaveCount(1);
        }
Exemplo n.º 12
0
        public void SlidesAddExternal_AddsSpecifiedExternalSlideWithKeepingSourceFormatting_WhenKeepSourceFormatFlagIsTrue()
        {
            // Arrange
            IPresentation sourPresentation  = _fixture.Pre001;
            IPresentation destPresentation  = SCPresentation.Open(Properties.Resources._002, true);
            int           originSlidesCount = destPresentation.Slides.Count;
            int           originFontSize    = 60;
            ISlide        copiedSlide       = sourPresentation.Slides[0];
            var           mStream           = new MemoryStream();

            // Act
            ISlide addedSlide = destPresentation.Slides.AddExternal(copiedSlide, true);

            // Arrange
            destPresentation.Slides.Count.Should().Be(originSlidesCount + 1);
            IAutoShape addedShape = (IAutoShape)addedSlide.Shapes.First(sp => sp.Id == 2);

            addedShape.TextBox.Paragraphs[0].Portions[0].Font.Size.Should().Be(originFontSize);

            destPresentation.SaveAs(mStream);
            destPresentation = SCPresentation.Open(mStream, false);
            addedShape       = (IAutoShape)destPresentation.Slides.Last().Shapes.First(sp => sp.Id == 2);
            addedShape.TextBox.Paragraphs[0].Portions[0].Font.Size.Should().Be(originFontSize);
        }