Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/ChartUpdaterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.IO;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class CuTests
{
Expand Down
4 changes: 2 additions & 2 deletions OpenXmlPowerTools.Tests/ColorParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using SkiaSharp;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class ColorParserTests
{
Expand Down Expand Up @@ -53,4 +53,4 @@ public void ShouldRejectInvalidColors(string? input)
Assert.False(success);
}
}
}
}
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/CssPropertyValueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using SkiaSharp;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class CssPropertyValueTests
{
Expand Down
18 changes: 9 additions & 9 deletions OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using Codeuctivity.OpenXmlPowerTools;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml.Validation;
using DocumentFormat.OpenXml.Wordprocessing;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using Xunit;
using System.Globalization;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class DaTests
{
Expand Down Expand Up @@ -126,7 +126,7 @@ public void DA101(string name, string data, bool err)
ms.Write(afterAssembling.DocumentByteArray, 0, afterAssembling.DocumentByteArray.Length);
using var wDoc = WordprocessingDocument.Open(ms, true);
var v = new OpenXmlValidator();
var valErrors = v.Validate(wDoc).Where(ve => !s_ExpectedErrors.Contains(ve.Description));
var valErrors = v.Validate(wDoc, TestContext.Current.CancellationToken).Where(ve => !s_ExpectedErrors.Contains(ve.Description));

var sb = new StringBuilder();
foreach (var item in valErrors.Select(r => r.Description).OrderBy(t => t).Distinct())
Expand Down Expand Up @@ -215,7 +215,7 @@ public void DA103_UseXmlDocument(string name, string data, bool err)
ms.Write(afterAssembling.DocumentByteArray, 0, afterAssembling.DocumentByteArray.Length);
using var wDoc = WordprocessingDocument.Open(ms, true);
var v = new OpenXmlValidator();
var valErrors = v.Validate(wDoc).Where(ve => !s_ExpectedErrors.Contains(ve.Description));
var valErrors = v.Validate(wDoc, TestContext.Current.CancellationToken).Where(ve => !s_ExpectedErrors.Contains(ve.Description));
Assert.Empty(valErrors);
}

Expand Down Expand Up @@ -515,8 +515,8 @@ private static string InnerText(XContainer e)
.StringConcatenate();
}

private static readonly List<string> s_ExpectedErrors = new List<string>()
{
private static readonly List<string> s_ExpectedErrors =
[
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:evenHBand' attribute is not declared.",
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:evenVBand' attribute is not declared.",
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:firstColumn' attribute is not declared.",
Expand All @@ -531,6 +531,6 @@ private static string InnerText(XContainer e)
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:noVBand' attribute is not declared.",
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:oddHBand' attribute is not declared.",
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:oddVBand' attribute is not declared.",
};
];
}
}
}
132 changes: 65 additions & 67 deletions OpenXmlPowerTools.Tests/DocumentBuilderTests.cs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions OpenXmlPowerTools.Tests/FormattingAssemblerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Text;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class FaTests
{
Expand Down Expand Up @@ -49,7 +49,7 @@ public void FA001_DocumentsWithRevTracking(string testId, string src)
var thisTestTempDir = new DirectoryInfo(Path.Combine(rootTempDir.FullName, testId));
if (thisTestTempDir.Exists)
{
Assert.True(false, "Duplicate test id: " + testId);
Assert.Fail("Duplicate test id: " + testId);
}
else
{
Expand Down Expand Up @@ -100,12 +100,12 @@ private void Validate(FileInfo fi)
sb.Append(item.Description).Append(Environment.NewLine);
}
var s = sb.ToString();
Assert.True(false, s);
Assert.Fail(s);
}
}

private static readonly List<string> s_ExpectedErrors = new List<string>()
{
private static readonly List<string> s_ExpectedErrors =
[
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:evenHBand' attribute is not declared.",
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:evenVBand' attribute is not declared.",
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:firstColumn' attribute is not declared.",
Expand Down Expand Up @@ -135,6 +135,6 @@ private void Validate(FileInfo fi)
"The 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:customStyles' attribute is not declared.",
"The element has invalid child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:ins'.",
"The element has invalid child element 'http://schemas.openxmlformats.org/wordprocessingml/2006/main:del'.",
};
];
}
}
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/HtmlToWmlConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* this module do not require the HtmlAgilityPack to run.
*******************************************************************************************/

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class HwTests
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/HtmlToWmlReadAsXElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using HtmlAgilityPack;
#endif

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class HtmlToWmlReadAsXElement
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/ImageHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using SkiaSharp;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class ImageHandlerTests
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Xml.Linq;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class MarkupSimplifierTests
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/MetricsGetterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Xml.Linq;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class MgTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Codeuctivity.Tests.OpenXMLWordProcessingMLToHtmlConverter
namespace OpenXmlPowerTools.Tests.OpenXMLWordprocessingMLToHtmlConverter
{
internal class AllowedDiffInfo
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Xml.Linq;
using Xunit;

namespace Codeuctivity.Tests.OpenXMLWordProcessingMLToHtmlConverter
namespace OpenXmlPowerTools.Tests.OpenXMLWordprocessingMLToHtmlConverter
{
public class WmlToHtmlConverterHandlerTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using System.Xml.Linq;
using Xunit;

namespace Codeuctivity.Tests.OpenXMLWordProcessingMLToHtmlConverter
namespace OpenXmlPowerTools.Tests.OpenXMLWordprocessingMLToHtmlConverter
{
public class WmlToHtmlConverterTests
{
Expand Down Expand Up @@ -117,7 +117,7 @@ public async Task HC003_ContainsSubstring(string name, params string[] expectedS
var sourceDocx = new FileInfo(Path.Combine(sourceDir.FullName, name));
var settings = new WmlToHtmlConverterSettings(sourceDocx.FullName, new ImageHandler(), new TextDummyHandler(), new SymbolHandler(), new BreakHandler(), new FontHandler(), false);

var byteArray = await File.ReadAllBytesAsync(sourceDocx.FullName);
var byteArray = await File.ReadAllBytesAsync(sourceDocx.FullName, TestContext.Current.CancellationToken);
using var memoryStream = new MemoryStream();
memoryStream.Write(byteArray, 0, byteArray.Length);
using var wDoc = WordprocessingDocument.Open(memoryStream, true);
Expand Down Expand Up @@ -243,7 +243,7 @@ internal static async Task AssertImageIsEqual(string actualImagePath, string exp
Assert.Fail($"Expected PixelErrorCount less or equal {allowedPixelErrorCount} but was {result.PixelErrorCount}\nExpected {expectFullPath}\ndiffers to actual {actualFullPath}\n Diff is {allowedDiffInfo.NewDiffImageFileName} \nReplace {actualFullPath} with the new value or store the diff as {allowedDiffInfo.ExistingDiffImageFilename.First()}.");
}
}
catch (System.Exception ex) when (!(ex is Xunit.Sdk.FailException))
catch (System.Exception ex) when (ex is not Xunit.Sdk.FailException)
{
SaveToGithubActionsPickupTestresultsDirectory(actualFullPath, expectFullPath, allowedDiffInfo.NewDiffImageFileName);
}
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Xml.Linq;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class OpenXmlRegexTests
{
Expand Down
8 changes: 4 additions & 4 deletions OpenXmlPowerTools.Tests/PowerToolsBlockExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Xml.Linq;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class PowerToolsBlockExtensionsTests : TestsBase
{
Expand Down Expand Up @@ -52,7 +52,7 @@ public void MustBeginPowerToolsBlockToUsePowerTools()
// paragraph. This is caused by the GetXDocument method using the cached
// XDocument, i.e., the annotation, rather reading the part's stream again.
content = part.GetXDocument();
paragraphElements = content.Descendants(W.p).ToList();
paragraphElements = [.. content.Descendants(W.p)];
Assert.Single(paragraphElements);
Assert.Equal("First", paragraphElements[0].Value);

Expand All @@ -65,7 +65,7 @@ public void MustBeginPowerToolsBlockToUsePowerTools()
// Get content through the PowerTools in the exact same way as above.
// We should now see both paragraphs.
content = part.GetXDocument();
paragraphElements = content.Descendants(W.p).ToList();
paragraphElements = [.. content.Descendants(W.p)];
Assert.Equal(2, paragraphElements.Count);
Assert.Equal("First", paragraphElements[0].Value);
Assert.Equal("Second", paragraphElements[1].Value);
Expand Down Expand Up @@ -114,7 +114,7 @@ public void MustEndPowerToolsBlockToUseStronglyTypedClasses()
// Get the part's content through the SDK. Having reloaded the root element,
// we should still see both paragraphs.
body = part.Document.Body;
paragraphs = body.Elements<Paragraph>().ToList();
paragraphs = [.. body.Elements<Paragraph>()];
Assert.Equal(2, paragraphs.Count);
Assert.Equal("Added through SDK", paragraphs[0].InnerText);
Assert.Equal("Added through PowerTools", paragraphs[1].InnerText);
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/PowerToolsBlockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Xml.Linq;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class PowerToolsBlockTests : TestsBase
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/PtUtilTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class PtUtilTests
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/RevisionAccepterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class RaTests
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/RevisionProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class RpTests
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class CfTests
{
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/SmlToHtmlConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using Xunit;

namespace Codeuctivity.Tests
namespace OpenXmlPowerTools.Tests
{
public class ShTests
{
Expand Down
Loading
Loading