Skip to content

Commit

Permalink
SC-66: Rename test project on ShapeCrawler.Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ashahabov committed Feb 6, 2022
1 parent b76296e commit eb21d46
Show file tree
Hide file tree
Showing 75 changed files with 57 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
using System.Linq;
using FluentAssertions;
using ShapeCrawler.Charts;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Helpers;
using Xunit;
// ReSharper disable SuggestVarOrType_BuiltInTypes
// ReSharper disable SuggestVarOrType_SimpleTypes

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class ChartPointTests : ShapeCrawlerTest, IClassFixture<PresentationFixture>
{
Expand Down Expand Up @@ -103,9 +103,8 @@ public void Value_Setter_updates_chart_point(string filename, int slideNumber, s

// Assert
point.Value.Should().Be(newChartPointValue);

var stream = new MemoryStream();
presentation.SaveAs(stream);

presentation = SaveAndOpenPresentation(presentation);
chart = presentation.Slides[slideNumber].Shapes.GetByName<IChart>(shapeName);
point = chart.SeriesCollection[0].Points[0];
point.Value.Should().Be(newChartPointValue);
Expand All @@ -116,6 +115,7 @@ public static IEnumerable<object[]> TestCasesValueSetter()
yield return new object[] {"024_chart.pptx", 3, "Chart 4"};
yield return new object[] {"009_table.pptx", 3, "Chart 5"};
yield return new object[] {"charts-case001.pptx", 1, "chart"};
yield return new object[] {"charts-case002.pptx", 1, "Chart 1"};
yield return new object[] {"002.pptx", 1, "Chart 8"};
yield return new object[] {"021.pptx", 2, "Chart 3"};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
using FluentAssertions;
using ShapeCrawler.Charts;
using ShapeCrawler.Factories;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Tests.Properties;
using Xunit;

// ReSharper disable TooManyDeclarations
// ReSharper disable InconsistentNaming
// ReSharper disable TooManyChainedReferences

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
[SuppressMessage("ReSharper", "SuggestVarOrType_SimpleTypes")]
[SuppressMessage("ReSharper", "SuggestVarOrType_BuiltInTypes")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using System.Linq;
using FluentAssertions;
using ShapeCrawler.Drawing;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Tests.Properties;
using Xunit;

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class ColorFormatTests : IClassFixture<PresentationFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
using FluentAssertions;
using ShapeCrawler.AutoShapes;
using ShapeCrawler.Exceptions;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Tests.Properties;
using Xunit;
// ReSharper disable SuggestVarOrType_SimpleTypes

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class FontTests : IClassFixture<PresentationFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Xml.Linq;
using SharpCompress.Common;

namespace ShapeCrawler.Tests.Unit.Helpers
namespace ShapeCrawler.Tests.Helpers
{
public class PptxValidator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ShapeCrawler.Tests.Unit.Helpers
namespace ShapeCrawler.Tests.Helpers
{
public class PresentationFixture
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ShapeCrawler.Tests.Unit.Helpers
namespace ShapeCrawler.Tests.Helpers
{
public class SlideElementQuery
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Properties;

namespace ShapeCrawler.Tests.Unit.Helpers
namespace ShapeCrawler.Tests.Helpers
{
public static class TestFiles
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Reflection;

namespace ShapeCrawler.Tests.Unit.Helpers
namespace ShapeCrawler.Tests.Helpers
{
public static class TestHelper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
using ShapeCrawler.Collections;
using ShapeCrawler.Exceptions;
using ShapeCrawler.Tables;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Tests.Properties;
using Xunit;

// ReSharper disable All
// ReSharper disable TooManyChainedReferences
// ReSharper disable TooManyDeclarations

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class ParagraphPortionTests : IClassFixture<PresentationFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
using System.IO;
using System.Linq;
using FluentAssertions;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Helpers;
using Xunit;

// ReSharper disable TooManyChainedReferences
// ReSharper disable TooManyDeclarations

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class PictureTests : IClassFixture<PresentationFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// ReSharper disable TooManyDeclarations

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
/// <summary>
/// Represents test for <see cref="PlaceholderLocationData"/> class APIs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
using ShapeCrawler.Exceptions;
using ShapeCrawler.Factories;
using ShapeCrawler.Statics;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Helpers;
using Xunit;

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class PresentationTests : IClassFixture<PresentationFixture>
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<EmbeddedResource Include="Resource\Charts\charts-case001.pptx" />
<None Remove="Resource\002.pptx" />
<EmbeddedResource Include="Resource\002.pptx" />
<None Remove="Resource\Charts\charts-case002.pptx" />
<EmbeddedResource Include="Resource\Charts\charts-case002.pptx" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Reflection;
using ClosedXML.Excel;

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public abstract class ShapeCrawlerTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
using ShapeCrawler.Drawing;
using ShapeCrawler.OLEObjects;
using ShapeCrawler.Shapes;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Tests.Properties;
using Xunit;

// ReSharper disable TooManyDeclarations
// ReSharper disable InconsistentNaming
// ReSharper disable TooManyChainedReferences

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class ShapeTests : ShapeCrawlerTest, IClassFixture<PresentationFixture>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Linq;
using FluentAssertions;
using ShapeCrawler.Shapes;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Helpers;
using Xunit;

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class SlideMasterTests : IClassFixture<PresentationFixture>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
using System.Linq;
using FluentAssertions;
using ShapeCrawler.Shapes;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Video;
using Xunit;

// ReSharper disable SuggestVarOrType_BuiltInTypes
// ReSharper disable TooManyChainedReferences
// ReSharper disable TooManyDeclarations

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
[SuppressMessage("ReSharper", "SuggestVarOrType_SimpleTypes")]
public class SlideTests : ShapeCrawlerTest, IClassFixture<PresentationFixture>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
using FluentAssertions;
using ShapeCrawler.Collections;
using ShapeCrawler.Tables;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Tests.Properties;
using Xunit;

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
[SuppressMessage("ReSharper", "SuggestVarOrType_SimpleTypes")]
[SuppressMessage("ReSharper", "SuggestVarOrType_BuiltInTypes")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
using ShapeCrawler.Exceptions;
using ShapeCrawler.Shapes;
using ShapeCrawler.Statics;
using ShapeCrawler.Tests.Unit.Helpers;
using ShapeCrawler.Tests.Unit.Properties;
using ShapeCrawler.Tests.Helpers;
using ShapeCrawler.Tests.Properties;
using Xunit;

// ReSharper disable All
// ReSharper disable TooManyChainedReferences
// ReSharper disable TooManyDeclarations

namespace ShapeCrawler.Tests.Unit
namespace ShapeCrawler.Tests
{
public class TextBoxTests : ShapeCrawlerTest, IClassFixture<PresentationFixture>
{
Expand Down
2 changes: 1 addition & 1 deletion ShapeCrawler.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShapeCrawler", "ShapeCrawler\ShapeCrawler.csproj", "{4A633D84-856C-49A3-A76E-59291CF76A6F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShapeCrawler.Tests.Unit", "ShapeCrawler.Tests.Unit\ShapeCrawler.Tests.Unit.csproj", "{72CE74E1-91AF-4F35-AA2A-C925B84B0CB9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShapeCrawler.Tests", "ShapeCrawler.Tests\ShapeCrawler.Tests.csproj", "{72CE74E1-91AF-4F35-AA2A-C925B84B0CB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
9 changes: 9 additions & 0 deletions ShapeCrawler/Charts/ChartWorkbook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ internal X.Cell GetXCell(string sheetName, string cellAddress)

return sheetXCells.First(xCell => xCell.CellReference == cellAddress);
}

internal X.Cell? GetXCellOrDefault(string sheetName, string cellAddress)
{
var chartSheet = this.WorkbookPart.Workbook.Sheets!.Elements<X.Sheet>().First(xSheet => xSheet.Name == sheetName);
var worksheetPart = (WorksheetPart)this.WorkbookPart.GetPartById(chartSheet.Id!);
var sheetXCells = worksheetPart.Worksheet.Descendants<X.Cell>();

return sheetXCells.FirstOrDefault(xCell => xCell.CellReference == cellAddress);
}

private SpreadsheetDocument GetSpreadsheetDocument()
{
Expand Down
2 changes: 1 addition & 1 deletion ShapeCrawler/Charts/IChartPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private void UpdateValue(double value)
return;
}

var xCell = this.parentChart.ChartWorkbook.GetXCell(this.sheetName, this.address);
var xCell = this.parentChart.ChartWorkbook.GetXCellOrDefault(this.sheetName, this.address);
xCell.DataType = new EnumValue<X.CellValues>(X.CellValues.Number);
xCell.CellValue = new X.CellValue(value);
}
Expand Down

0 comments on commit eb21d46

Please sign in to comment.