Skip to content

Commit

Permalink
Fix xunit warnings (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
twsouthwick committed Mar 2, 2018
1 parent 21d8016 commit 994db19
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 52 deletions.
8 changes: 4 additions & 4 deletions OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs
Expand Up @@ -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);
}
}

Expand All @@ -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));
Expand Down Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions OpenXmlPowerTools.Tests/HtmlConverterTests.cs
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
8 changes: 4 additions & 4 deletions OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/MetricsGetterTests.cs
Expand Up @@ -71,7 +71,7 @@ public void MG001(string name)
metrics = MetricsGetter.GetPptxMetrics(pmlDocument, settings);
}

Assert.NotEqual(null, metrics);
Assert.NotNull(metrics);
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs
Expand Up @@ -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»");
}
}

Expand Down Expand Up @@ -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’");
}
}

Expand Down Expand Up @@ -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"));
}
}

Expand Down
6 changes: 3 additions & 3 deletions OpenXmlPowerTools.Tests/PowerToolsBlockExtensionsTests.cs
Expand Up @@ -48,7 +48,7 @@ public void MustBeginPowerToolsBlockToUsePowerTools()
// by using the strongly typed SDK classes.
XDocument content = part.GetXDocument();
List<XElement> 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
Expand All @@ -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
Expand Down Expand Up @@ -121,7 +121,7 @@ public void MustEndPowerToolsBlockToUseStronglyTypedClasses()
// added through the SDK, not what we added through the PowerTools functionality.
body = part.Document.Body;
List<Paragraph> paragraphs = body.Elements<Paragraph>().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
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/PowerToolsBlockTests.cs
Expand Up @@ -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<XElement> 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.
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/PtUtilTests.cs
Expand Up @@ -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);
}

}
Expand Down
16 changes: 0 additions & 16 deletions OpenXmlPowerTools.Tests/RevisionProcessorTests.cs
Expand Up @@ -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")));
Expand Down
6 changes: 0 additions & 6 deletions OpenXmlPowerTools.Tests/SmlCellFormatterTests.cs
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/SpreadsheetWriterTests.cs
Expand Up @@ -347,7 +347,7 @@ private void Validate(FileInfo fi)
}
#endif

Assert.Equal(0, errors.Count());
Assert.Empty(errors);
}
}

Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/StronglyTypedBlockTests.cs
Expand Up @@ -49,7 +49,7 @@ public void CanUseStronglyTypedBlockToDemarcateApis()
// Assert that we can see the paragraph added through the PowerTools.
Body body = part.Document.Body;
List<Paragraph> paragraphs = body.Elements<Paragraph>().ToList();
Assert.Equal(1, paragraphs.Count);
Assert.Single(paragraphs);
Assert.Equal("Added through PowerTools", paragraphs[0].InnerText);

// Add a paragraph through the SDK.
Expand Down
2 changes: 1 addition & 1 deletion OpenXmlPowerTools.Tests/UnicodeMapperTests.cs
Expand Up @@ -76,7 +76,7 @@ public void CanCreateCoalescedRuns()
List<XElement> textRuns = UnicodeMapper.StringToCoalescedRunList(textString, null);
List<XElement> 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);
Expand Down
4 changes: 3 additions & 1 deletion OpenXmlPowerTools.Tests/WmlComparerTests2.cs
Expand Up @@ -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));

Expand Down

0 comments on commit 994db19

Please sign in to comment.