diff --git a/OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs b/OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs index 382522b6..28bfe8e9 100644 --- a/OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs +++ b/OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs @@ -163,7 +163,7 @@ public void DA101(string name, string data, bool err) Console.WriteLine(z); #endif - Assert.Equal(0, valErrors.Count()); + Assert.Empty(valErrors); } } @@ -186,8 +186,8 @@ public void DA259(string name, string data, bool err) } [Theory] - [InlineData("DA024-TrackedRevisions.docx", "DA-Data.xml", true)] - public void DA102_Throws(string name, string data, bool err) + [InlineData("DA024-TrackedRevisions.docx", "DA-Data.xml")] + public void DA102_Throws(string name, string data) { FileInfo templateDocx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name)); FileInfo dataFile = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, data)); @@ -226,7 +226,7 @@ public void DA103_UseXmlDocument(string name, string data, bool err) { OpenXmlValidator v = new OpenXmlValidator(); var valErrors = v.Validate(wDoc).Where(ve => !s_ExpectedErrors.Contains(ve.Description)); - Assert.Equal(0, valErrors.Count()); + Assert.Empty(valErrors); } } diff --git a/OpenXmlPowerTools.Tests/HtmlConverterTests.cs b/OpenXmlPowerTools.Tests/HtmlConverterTests.cs index 62962ebb..6c6bc372 100644 --- a/OpenXmlPowerTools.Tests/HtmlConverterTests.cs +++ b/OpenXmlPowerTools.Tests/HtmlConverterTests.cs @@ -139,7 +139,7 @@ public void HC002_NoCssClasses(string name) ConvertToHtmlNoCssClasses(sourceDocx, oxPtConvertedDestHtml); } - public static void CopyFormattingAssembledDocx(FileInfo source, FileInfo dest) + private static void CopyFormattingAssembledDocx(FileInfo source, FileInfo dest) { var ba = File.ReadAllBytes(source.FullName); using (MemoryStream ms = new MemoryStream()) @@ -188,7 +188,7 @@ public static void CopyFormattingAssembledDocx(FileInfo source, FileInfo dest) } } - public static void ConvertToHtml(FileInfo sourceDocx, FileInfo destFileName) + private static void ConvertToHtml(FileInfo sourceDocx, FileInfo destFileName) { byte[] byteArray = File.ReadAllBytes(sourceDocx.FullName); using (MemoryStream memoryStream = new MemoryStream()) @@ -282,7 +282,7 @@ public static void ConvertToHtml(FileInfo sourceDocx, FileInfo destFileName) } } - public static void ConvertToHtmlNoCssClasses(FileInfo sourceDocx, FileInfo destFileName) + private static void ConvertToHtmlNoCssClasses(FileInfo sourceDocx, FileInfo destFileName) { byte[] byteArray = File.ReadAllBytes(sourceDocx.FullName); using (MemoryStream memoryStream = new MemoryStream()) diff --git a/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs b/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs index 4bd76c85..3a6fcfc0 100644 --- a/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs +++ b/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs @@ -133,12 +133,12 @@ public void CanRemoveContentControls() public void CanRemoveGoBackBookmarks() { XDocument partDocument = XDocument.Parse(GoBackBookmarkDocumentXmlString); - Assert.True(partDocument + Assert.Contains(partDocument .Descendants(W.bookmarkStart) - .Any(e => e.Attribute(W.name).Value == "_GoBack" && e.Attribute(W.id).Value == "0")); - Assert.True(partDocument +, e => e.Attribute(W.name).Value == "_GoBack" && e.Attribute(W.id).Value == "0"); + Assert.Contains(partDocument .Descendants(W.bookmarkEnd) - .Any(e => e.Attribute(W.id).Value == "0")); +, e => e.Attribute(W.id).Value == "0"); using (var stream = new MemoryStream()) using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(stream, DocumentType)) diff --git a/OpenXmlPowerTools.Tests/MetricsGetterTests.cs b/OpenXmlPowerTools.Tests/MetricsGetterTests.cs index c4e26a59..ff11488c 100644 --- a/OpenXmlPowerTools.Tests/MetricsGetterTests.cs +++ b/OpenXmlPowerTools.Tests/MetricsGetterTests.cs @@ -71,7 +71,7 @@ public void MG001(string name) metrics = MetricsGetter.GetPptxMetrics(pmlDocument, settings); } - Assert.NotEqual(null, metrics); + Assert.NotNull(metrics); } } } diff --git a/OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs b/OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs index c0a30a3e..417ae62f 100644 --- a/OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs +++ b/OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs @@ -276,11 +276,11 @@ public void CanReplaceTextWithQuotationMarksAndAddTrackedChangesWhenReplacing() "Text can be enclosed in ‘changed normal double quotes’ and in ‘changed double angle quotation marks’.", innerText); - Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed normal double quotes’")); - Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed double angle quotation marks’")); + Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed normal double quotes’"); + Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed double angle quotation marks’"); - Assert.True(p.Elements(W.del).Any(e => InnerDelText(e) == "“normal double quotes”")); - Assert.True(p.Elements(W.del).Any(e => InnerDelText(e) == "«double angle quotation marks»")); + Assert.Contains(p.Elements(W.del), e => InnerDelText(e) == "“normal double quotes”"); + Assert.Contains(p.Elements(W.del), e => InnerDelText(e) == "«double angle quotation marks»"); } } @@ -314,8 +314,8 @@ public void CanReplaceTextWithQuotationMarksAndTrackedChanges() "Text can be enclosed in ‘changed normal double quotes’ and in ‘changed double angle quotation marks’.", innerText); - Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed normal double quotes’")); - Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed double angle quotation marks’")); + Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed normal double quotes’"); + Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed double angle quotation marks’"); } } @@ -344,10 +344,9 @@ public void CanReplaceTextWithSymbolsAndTrackedChanges() Assert.Equal(1, count); Assert.Equal("We can also use symbols such as \uF028 or \uF028.", innerText); - Assert.True(p.Descendants(W.ins).Any( - ins => ins.Descendants(W.sym).Any( + Assert.Contains(p.Descendants(W.ins), ins => ins.Descendants(W.sym).Any( sym => sym.Attribute(W.font).Value == "Wingdings" && - sym.Attribute(W._char).Value == "F028"))); + sym.Attribute(W._char).Value == "F028")); } } diff --git a/OpenXmlPowerTools.Tests/PowerToolsBlockExtensionsTests.cs b/OpenXmlPowerTools.Tests/PowerToolsBlockExtensionsTests.cs index b072860f..a0ffb420 100644 --- a/OpenXmlPowerTools.Tests/PowerToolsBlockExtensionsTests.cs +++ b/OpenXmlPowerTools.Tests/PowerToolsBlockExtensionsTests.cs @@ -48,7 +48,7 @@ public void MustBeginPowerToolsBlockToUsePowerTools() // by using the strongly typed SDK classes. XDocument content = part.GetXDocument(); List paragraphElements = content.Descendants(W.p).ToList(); - Assert.Equal(1, paragraphElements.Count); + Assert.Single(paragraphElements); Assert.Equal("First", paragraphElements[0].Value); // This demonstrates the usage of the EndPowerToolsBlock method to @@ -69,7 +69,7 @@ public void MustBeginPowerToolsBlockToUsePowerTools() // XDocument, i.e., the annotation, rather reading the part's stream again. content = part.GetXDocument(); paragraphElements = content.Descendants(W.p).ToList(); - Assert.Equal(1, paragraphElements.Count); + Assert.Single(paragraphElements); Assert.Equal("First", paragraphElements[0].Value); // To make the GetXDocument read the parts' streams, we need to begin @@ -121,7 +121,7 @@ public void MustEndPowerToolsBlockToUseStronglyTypedClasses() // added through the SDK, not what we added through the PowerTools functionality. body = part.Document.Body; List paragraphs = body.Elements().ToList(); - Assert.Equal(1, paragraphs.Count); + Assert.Single(paragraphs); Assert.Equal("Added through SDK", paragraphs[0].InnerText); // Now, let's end the PowerTools Block, which reloads the root element of this diff --git a/OpenXmlPowerTools.Tests/PowerToolsBlockTests.cs b/OpenXmlPowerTools.Tests/PowerToolsBlockTests.cs index b2db5a05..a08041fc 100644 --- a/OpenXmlPowerTools.Tests/PowerToolsBlockTests.cs +++ b/OpenXmlPowerTools.Tests/PowerToolsBlockTests.cs @@ -47,7 +47,7 @@ public void CanUsePowerToolsBlockToDemarcateApis() // Assert that we can see the paragraph added through the strongly typed classes. XDocument content = part.GetXDocument(); List paragraphElements = content.Descendants(W.p).ToList(); - Assert.Equal(1, paragraphElements.Count); + Assert.Single(paragraphElements); Assert.Equal("Added through SDK", paragraphElements[0].Value); // Add a paragraph through the PowerTools. diff --git a/OpenXmlPowerTools.Tests/PtUtilTests.cs b/OpenXmlPowerTools.Tests/PtUtilTests.cs index 85ee870f..8d000ad4 100644 --- a/OpenXmlPowerTools.Tests/PtUtilTests.cs +++ b/OpenXmlPowerTools.Tests/PtUtilTests.cs @@ -46,7 +46,7 @@ public void PU001(string name) Assert.True(p.ContentType != null); Assert.True(p.MimeVersion != null); Assert.True(p.Parts.Length != 0); - Assert.False(p.Parts.Any(part => part.ContentType == null || part.ContentLocation == null)); + Assert.DoesNotContain(p.Parts, part => part.ContentType == null || part.ContentLocation == null); } } diff --git a/OpenXmlPowerTools.Tests/RevisionProcessorTests.cs b/OpenXmlPowerTools.Tests/RevisionProcessorTests.cs index 1e487f6c..98353754 100644 --- a/OpenXmlPowerTools.Tests/RevisionProcessorTests.cs +++ b/OpenXmlPowerTools.Tests/RevisionProcessorTests.cs @@ -93,24 +93,8 @@ public class RpTests [InlineData("RP/RP048-Deleted-Inserted-Para-Mark.docx")] [InlineData("RP/RP049-Deleted-Para-Before-Table.docx")] [InlineData("RP/RP050-Deleted-Footnote.docx")] - //[InlineData("RP/")] [InlineData("RP/RP052-Deleted-Para-Mark.docx")] - //[InlineData("RP/")] - //[InlineData("RP/")] - //[InlineData("RP/")] - //[InlineData("RP/")] - //[InlineData("RP/")] - //[InlineData("RP/")] - //[InlineData("RP/")] - //[InlineData("RP/")] - //[InlineData("RP/")] - public void RP001(string name) - { - DoTest(name); - } - - public void DoTest(string name) { var sourceFi = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name)); var baselineAcceptedFi = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name.Replace(".docx", "-Accepted.docx"))); diff --git a/OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs b/OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs index 605788fe..489ae196 100644 --- a/OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs +++ b/OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs @@ -84,12 +84,6 @@ public class CfTests [InlineData("h:mm", "42344.295405092591", "7:05", null)] [InlineData("h:mm:ss", "42344.295405092591", "7:05:23", null)] [InlineData("m/d/yy h:mm", "42344.295405092591", "12/6/15 7:05", null)] - [InlineData("#,##0.00", "1.1000000000000001", "1.10", null)] - [InlineData("#,##0.00", "10.1", "10.10", null)] - [InlineData("#,##0.00", "1000.1", "1,000.10", null)] - [InlineData("#,##0.00", "1000000.1", "1,000,000.10", null)] - [InlineData("#,##0.00", "100000000.09999999", "100,000,000.10", null)] - [InlineData("#,##0.00", "100000000.09999999", "100,000,000.10", null)] [InlineData("#,##0 ;(#,##0)", "100", "100", null)] [InlineData("#,##0 ;(#,##0)", "-100", "(100)", null)] [InlineData("#,##0 ;[Red](#,##0)", "100", "100", null)] diff --git a/OpenXmlPowerTools.Tests/SpreadsheetWriterTests.cs b/OpenXmlPowerTools.Tests/SpreadsheetWriterTests.cs index d0ff4477..d51180ee 100644 --- a/OpenXmlPowerTools.Tests/SpreadsheetWriterTests.cs +++ b/OpenXmlPowerTools.Tests/SpreadsheetWriterTests.cs @@ -347,7 +347,7 @@ private void Validate(FileInfo fi) } #endif - Assert.Equal(0, errors.Count()); + Assert.Empty(errors); } } diff --git a/OpenXmlPowerTools.Tests/StronglyTypedBlockTests.cs b/OpenXmlPowerTools.Tests/StronglyTypedBlockTests.cs index 4e8e5af4..eaa39deb 100644 --- a/OpenXmlPowerTools.Tests/StronglyTypedBlockTests.cs +++ b/OpenXmlPowerTools.Tests/StronglyTypedBlockTests.cs @@ -49,7 +49,7 @@ public void CanUseStronglyTypedBlockToDemarcateApis() // Assert that we can see the paragraph added through the PowerTools. Body body = part.Document.Body; List paragraphs = body.Elements().ToList(); - Assert.Equal(1, paragraphs.Count); + Assert.Single(paragraphs); Assert.Equal("Added through PowerTools", paragraphs[0].InnerText); // Add a paragraph through the SDK. diff --git a/OpenXmlPowerTools.Tests/UnicodeMapperTests.cs b/OpenXmlPowerTools.Tests/UnicodeMapperTests.cs index c663947c..feb3ba4c 100644 --- a/OpenXmlPowerTools.Tests/UnicodeMapperTests.cs +++ b/OpenXmlPowerTools.Tests/UnicodeMapperTests.cs @@ -76,7 +76,7 @@ public void CanCreateCoalescedRuns() List textRuns = UnicodeMapper.StringToCoalescedRunList(textString, null); List mixedRuns = UnicodeMapper.StringToCoalescedRunList(mixedString, null); - Assert.Equal(1, textRuns.Count); + Assert.Single(textRuns); Assert.Equal(5, mixedRuns.Count); Assert.Equal("First", mixedRuns.Elements(W.t).Skip(0).First().Value); diff --git a/OpenXmlPowerTools.Tests/WmlComparerTests2.cs b/OpenXmlPowerTools.Tests/WmlComparerTests2.cs index 001372ec..1038d7c4 100644 --- a/OpenXmlPowerTools.Tests/WmlComparerTests2.cs +++ b/OpenXmlPowerTools.Tests/WmlComparerTests2.cs @@ -47,9 +47,11 @@ public class WcTests2 [InlineData("CZ-1010", "CZ/CZ002-Multi-Paragraphs.docx", "CZ/CZ002-Multi-Paragraphs-Mod.docx", 1)] [InlineData("CZ-1020", "CZ/CZ003-Multi-Paragraphs.docx", "CZ/CZ003-Multi-Paragraphs-Mod.docx", 1)] [InlineData("CZ-1030", "CZ/CZ004-Multi-Paragraphs-in-Cell.docx", "CZ/CZ004-Multi-Paragraphs-in-Cell-Mod.docx", 1)] - public void CZ001_CompareTrackedInPrev(string testId, string name1, string name2, int revisionCount) { + // TODO: Do we need to keep the revision count parameter? + Assert.Equal(1, revisionCount); + FileInfo source1Docx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name1)); FileInfo source2Docx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name2));