Skip to content

Commit 994db19

Browse files
authored
Fix xunit warnings (#209)
1 parent 21d8016 commit 994db19

14 files changed

+31
-52
lines changed

Diff for: OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void DA101(string name, string data, bool err)
163163
Console.WriteLine(z);
164164
#endif
165165

166-
Assert.Equal(0, valErrors.Count());
166+
Assert.Empty(valErrors);
167167
}
168168
}
169169

@@ -186,8 +186,8 @@ public void DA259(string name, string data, bool err)
186186
}
187187

188188
[Theory]
189-
[InlineData("DA024-TrackedRevisions.docx", "DA-Data.xml", true)]
190-
public void DA102_Throws(string name, string data, bool err)
189+
[InlineData("DA024-TrackedRevisions.docx", "DA-Data.xml")]
190+
public void DA102_Throws(string name, string data)
191191
{
192192
FileInfo templateDocx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name));
193193
FileInfo dataFile = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, data));
@@ -226,7 +226,7 @@ public void DA103_UseXmlDocument(string name, string data, bool err)
226226
{
227227
OpenXmlValidator v = new OpenXmlValidator();
228228
var valErrors = v.Validate(wDoc).Where(ve => !s_ExpectedErrors.Contains(ve.Description));
229-
Assert.Equal(0, valErrors.Count());
229+
Assert.Empty(valErrors);
230230
}
231231
}
232232

Diff for: OpenXmlPowerTools.Tests/HtmlConverterTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void HC002_NoCssClasses(string name)
139139
ConvertToHtmlNoCssClasses(sourceDocx, oxPtConvertedDestHtml);
140140
}
141141

142-
public static void CopyFormattingAssembledDocx(FileInfo source, FileInfo dest)
142+
private static void CopyFormattingAssembledDocx(FileInfo source, FileInfo dest)
143143
{
144144
var ba = File.ReadAllBytes(source.FullName);
145145
using (MemoryStream ms = new MemoryStream())
@@ -188,7 +188,7 @@ public static void CopyFormattingAssembledDocx(FileInfo source, FileInfo dest)
188188
}
189189
}
190190

191-
public static void ConvertToHtml(FileInfo sourceDocx, FileInfo destFileName)
191+
private static void ConvertToHtml(FileInfo sourceDocx, FileInfo destFileName)
192192
{
193193
byte[] byteArray = File.ReadAllBytes(sourceDocx.FullName);
194194
using (MemoryStream memoryStream = new MemoryStream())
@@ -282,7 +282,7 @@ public static void ConvertToHtml(FileInfo sourceDocx, FileInfo destFileName)
282282
}
283283
}
284284

285-
public static void ConvertToHtmlNoCssClasses(FileInfo sourceDocx, FileInfo destFileName)
285+
private static void ConvertToHtmlNoCssClasses(FileInfo sourceDocx, FileInfo destFileName)
286286
{
287287
byte[] byteArray = File.ReadAllBytes(sourceDocx.FullName);
288288
using (MemoryStream memoryStream = new MemoryStream())

Diff for: OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ public void CanRemoveContentControls()
133133
public void CanRemoveGoBackBookmarks()
134134
{
135135
XDocument partDocument = XDocument.Parse(GoBackBookmarkDocumentXmlString);
136-
Assert.True(partDocument
136+
Assert.Contains(partDocument
137137
.Descendants(W.bookmarkStart)
138-
.Any(e => e.Attribute(W.name).Value == "_GoBack" && e.Attribute(W.id).Value == "0"));
139-
Assert.True(partDocument
138+
, e => e.Attribute(W.name).Value == "_GoBack" && e.Attribute(W.id).Value == "0");
139+
Assert.Contains(partDocument
140140
.Descendants(W.bookmarkEnd)
141-
.Any(e => e.Attribute(W.id).Value == "0"));
141+
, e => e.Attribute(W.id).Value == "0");
142142

143143
using (var stream = new MemoryStream())
144144
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(stream, DocumentType))

Diff for: OpenXmlPowerTools.Tests/MetricsGetterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void MG001(string name)
7171
metrics = MetricsGetter.GetPptxMetrics(pmlDocument, settings);
7272
}
7373

74-
Assert.NotEqual(null, metrics);
74+
Assert.NotNull(metrics);
7575
}
7676
}
7777
}

Diff for: OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs

+8-9
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,11 @@ public void CanReplaceTextWithQuotationMarksAndAddTrackedChangesWhenReplacing()
276276
"Text can be enclosed in ‘changed normal double quotes’ and in ‘changed double angle quotation marks’.",
277277
innerText);
278278

279-
Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed normal double quotes’"));
280-
Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed double angle quotation marks’"));
279+
Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed normal double quotes’");
280+
Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed double angle quotation marks’");
281281

282-
Assert.True(p.Elements(W.del).Any(e => InnerDelText(e) == "“normal double quotes”"));
283-
Assert.True(p.Elements(W.del).Any(e => InnerDelText(e) == "«double angle quotation marks»"));
282+
Assert.Contains(p.Elements(W.del), e => InnerDelText(e) == "“normal double quotes”");
283+
Assert.Contains(p.Elements(W.del), e => InnerDelText(e) == "«double angle quotation marks»");
284284
}
285285
}
286286

@@ -314,8 +314,8 @@ public void CanReplaceTextWithQuotationMarksAndTrackedChanges()
314314
"Text can be enclosed in ‘changed normal double quotes’ and in ‘changed double angle quotation marks’.",
315315
innerText);
316316

317-
Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed normal double quotes’"));
318-
Assert.True(p.Elements(W.ins).Any(e => InnerText(e) == "‘changed double angle quotation marks’"));
317+
Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed normal double quotes’");
318+
Assert.Contains(p.Elements(W.ins), e => InnerText(e) == "‘changed double angle quotation marks’");
319319
}
320320
}
321321

@@ -344,10 +344,9 @@ public void CanReplaceTextWithSymbolsAndTrackedChanges()
344344
Assert.Equal(1, count);
345345
Assert.Equal("We can also use symbols such as \uF028 or \uF028.", innerText);
346346

347-
Assert.True(p.Descendants(W.ins).Any(
348-
ins => ins.Descendants(W.sym).Any(
347+
Assert.Contains(p.Descendants(W.ins), ins => ins.Descendants(W.sym).Any(
349348
sym => sym.Attribute(W.font).Value == "Wingdings" &&
350-
sym.Attribute(W._char).Value == "F028")));
349+
sym.Attribute(W._char).Value == "F028"));
351350
}
352351
}
353352

Diff for: OpenXmlPowerTools.Tests/PowerToolsBlockExtensionsTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void MustBeginPowerToolsBlockToUsePowerTools()
4848
// by using the strongly typed SDK classes.
4949
XDocument content = part.GetXDocument();
5050
List<XElement> paragraphElements = content.Descendants(W.p).ToList();
51-
Assert.Equal(1, paragraphElements.Count);
51+
Assert.Single(paragraphElements);
5252
Assert.Equal("First", paragraphElements[0].Value);
5353

5454
// This demonstrates the usage of the EndPowerToolsBlock method to
@@ -69,7 +69,7 @@ public void MustBeginPowerToolsBlockToUsePowerTools()
6969
// XDocument, i.e., the annotation, rather reading the part's stream again.
7070
content = part.GetXDocument();
7171
paragraphElements = content.Descendants(W.p).ToList();
72-
Assert.Equal(1, paragraphElements.Count);
72+
Assert.Single(paragraphElements);
7373
Assert.Equal("First", paragraphElements[0].Value);
7474

7575
// To make the GetXDocument read the parts' streams, we need to begin
@@ -121,7 +121,7 @@ public void MustEndPowerToolsBlockToUseStronglyTypedClasses()
121121
// added through the SDK, not what we added through the PowerTools functionality.
122122
body = part.Document.Body;
123123
List<Paragraph> paragraphs = body.Elements<Paragraph>().ToList();
124-
Assert.Equal(1, paragraphs.Count);
124+
Assert.Single(paragraphs);
125125
Assert.Equal("Added through SDK", paragraphs[0].InnerText);
126126

127127
// Now, let's end the PowerTools Block, which reloads the root element of this

Diff for: OpenXmlPowerTools.Tests/PowerToolsBlockTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void CanUsePowerToolsBlockToDemarcateApis()
4747
// Assert that we can see the paragraph added through the strongly typed classes.
4848
XDocument content = part.GetXDocument();
4949
List<XElement> paragraphElements = content.Descendants(W.p).ToList();
50-
Assert.Equal(1, paragraphElements.Count);
50+
Assert.Single(paragraphElements);
5151
Assert.Equal("Added through SDK", paragraphElements[0].Value);
5252

5353
// Add a paragraph through the PowerTools.

Diff for: OpenXmlPowerTools.Tests/PtUtilTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void PU001(string name)
4646
Assert.True(p.ContentType != null);
4747
Assert.True(p.MimeVersion != null);
4848
Assert.True(p.Parts.Length != 0);
49-
Assert.False(p.Parts.Any(part => part.ContentType == null || part.ContentLocation == null));
49+
Assert.DoesNotContain(p.Parts, part => part.ContentType == null || part.ContentLocation == null);
5050
}
5151

5252
}

Diff for: OpenXmlPowerTools.Tests/RevisionProcessorTests.cs

-16
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,8 @@ public class RpTests
9393
[InlineData("RP/RP048-Deleted-Inserted-Para-Mark.docx")]
9494
[InlineData("RP/RP049-Deleted-Para-Before-Table.docx")]
9595
[InlineData("RP/RP050-Deleted-Footnote.docx")]
96-
//[InlineData("RP/")]
9796
[InlineData("RP/RP052-Deleted-Para-Mark.docx")]
98-
//[InlineData("RP/")]
99-
//[InlineData("RP/")]
100-
//[InlineData("RP/")]
101-
//[InlineData("RP/")]
102-
//[InlineData("RP/")]
103-
//[InlineData("RP/")]
104-
//[InlineData("RP/")]
105-
//[InlineData("RP/")]
106-
//[InlineData("RP/")]
107-
10897
public void RP001(string name)
109-
{
110-
DoTest(name);
111-
}
112-
113-
public void DoTest(string name)
11498
{
11599
var sourceFi = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name));
116100
var baselineAcceptedFi = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name.Replace(".docx", "-Accepted.docx")));

Diff for: OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs

-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ public class CfTests
8484
[InlineData("h:mm", "42344.295405092591", "7:05", null)]
8585
[InlineData("h:mm:ss", "42344.295405092591", "7:05:23", null)]
8686
[InlineData("m/d/yy h:mm", "42344.295405092591", "12/6/15 7:05", null)]
87-
[InlineData("#,##0.00", "1.1000000000000001", "1.10", null)]
88-
[InlineData("#,##0.00", "10.1", "10.10", null)]
89-
[InlineData("#,##0.00", "1000.1", "1,000.10", null)]
90-
[InlineData("#,##0.00", "1000000.1", "1,000,000.10", null)]
91-
[InlineData("#,##0.00", "100000000.09999999", "100,000,000.10", null)]
92-
[InlineData("#,##0.00", "100000000.09999999", "100,000,000.10", null)]
9387
[InlineData("#,##0 ;(#,##0)", "100", "100", null)]
9488
[InlineData("#,##0 ;(#,##0)", "-100", "(100)", null)]
9589
[InlineData("#,##0 ;[Red](#,##0)", "100", "100", null)]

Diff for: OpenXmlPowerTools.Tests/SpreadsheetWriterTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private void Validate(FileInfo fi)
347347
}
348348
#endif
349349

350-
Assert.Equal(0, errors.Count());
350+
Assert.Empty(errors);
351351
}
352352
}
353353

Diff for: OpenXmlPowerTools.Tests/StronglyTypedBlockTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void CanUseStronglyTypedBlockToDemarcateApis()
4949
// Assert that we can see the paragraph added through the PowerTools.
5050
Body body = part.Document.Body;
5151
List<Paragraph> paragraphs = body.Elements<Paragraph>().ToList();
52-
Assert.Equal(1, paragraphs.Count);
52+
Assert.Single(paragraphs);
5353
Assert.Equal("Added through PowerTools", paragraphs[0].InnerText);
5454

5555
// Add a paragraph through the SDK.

Diff for: OpenXmlPowerTools.Tests/UnicodeMapperTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void CanCreateCoalescedRuns()
7676
List<XElement> textRuns = UnicodeMapper.StringToCoalescedRunList(textString, null);
7777
List<XElement> mixedRuns = UnicodeMapper.StringToCoalescedRunList(mixedString, null);
7878

79-
Assert.Equal(1, textRuns.Count);
79+
Assert.Single(textRuns);
8080
Assert.Equal(5, mixedRuns.Count);
8181

8282
Assert.Equal("First", mixedRuns.Elements(W.t).Skip(0).First().Value);

Diff for: OpenXmlPowerTools.Tests/WmlComparerTests2.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ public class WcTests2
4747
[InlineData("CZ-1010", "CZ/CZ002-Multi-Paragraphs.docx", "CZ/CZ002-Multi-Paragraphs-Mod.docx", 1)]
4848
[InlineData("CZ-1020", "CZ/CZ003-Multi-Paragraphs.docx", "CZ/CZ003-Multi-Paragraphs-Mod.docx", 1)]
4949
[InlineData("CZ-1030", "CZ/CZ004-Multi-Paragraphs-in-Cell.docx", "CZ/CZ004-Multi-Paragraphs-in-Cell-Mod.docx", 1)]
50-
5150
public void CZ001_CompareTrackedInPrev(string testId, string name1, string name2, int revisionCount)
5251
{
52+
// TODO: Do we need to keep the revision count parameter?
53+
Assert.Equal(1, revisionCount);
54+
5355
FileInfo source1Docx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name1));
5456
FileInfo source2Docx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name2));
5557

0 commit comments

Comments
 (0)