Skip to content

Commit a20a85c

Browse files
authored
Merge 16232ae into db3f1e9
2 parents db3f1e9 + 16232ae commit a20a85c

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

src/doc/readmes/net-core/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# XMLUnit.NET
2+
3+
XMLUnit provides you with the tools to verify the XML you emit is the
4+
one you want to create.
5+
6+
It provides helpers to validate against an XML Schema, assert the
7+
values of XPath queries or compare XML documents against expected
8+
outcomes.
9+
10+
This package provides the core functionality and can be used
11+
stand-alone. In addition there are libraries providing NUnit
12+
constraints and a "placeholders" package that may simplify writing
13+
comparison tests in certain cases.
14+
15+
* [XMLUnit.NUnit2.Constraints - Constraints for NUnit 2.x ![nuget](https://img.shields.io/nuget/v/XMLUnit.NUnit2.Constraints.svg)](https://www.nuget.org/packages/XMLUnit.NUnit2.Constraints/)
16+
* [XMLUnit.NUnit3.Constraints - Constraints for NUnit 3.x ![nuget](https://img.shields.io/nuget/v/XMLUnit.NUnit3.Constraints.svg)](https://www.nuget.org/packages/XMLUnit.NUnit3.Constraints/)
17+
* [XMLUnit.NUnit4.Constraints - Constraints for NUnit 4.x ![nuget](https://img.shields.io/nuget/v/XMLUnit.NUnit4.Constraints.svg)](https://www.nuget.org/packages/XMLUnit.NUnit4.Constraints/)
18+
* [XMLUnit.Placeholders - simplifies comparisons for special cases ![nuget](https://img.shields.io/nuget/v/XMLUnit.Placeholders.svg)](https://www.nuget.org/packages/XMLUnit.Placeholders/)
19+
20+
[![Build status](https://ci.appveyor.com/api/projects/status/am34dfbr4vbcarr3?svg=true)]
21+
22+
## Requirements
23+
24+
XMLUnit requires .NET Standard 2.0 (tested with .NET 8 rigt now) and
25+
should still support .NET Framework 3.5 and Mono.
26+
27+
The core library hasn't got any dependencies itself.
28+
29+
## Usage
30+
31+
These are some really small examples, more is available as part of the
32+
[user guide](https://github.com/xmlunit/user-guide/wiki)
33+
34+
### Comparing Two Documents
35+
36+
```csharp
37+
ISource control = Input.FromFile("test-data/good.xml").Build();
38+
ISource test = Input.FromByteArray(CreateTestDocument()).Build();
39+
IDifferenceEngine diff = new DOMDifferenceEngine();
40+
diff.DifferenceListener += (comparison, outcome) => {
41+
Assert.Fail("found a difference: {}", comparison);
42+
};
43+
diff.Compare(control, test);
44+
```
45+
46+
or using the fluent builder API
47+
48+
```csharp
49+
Diff d = DiffBuilder.Compare(Input.FromFile("test-data/good.xml"))
50+
.WithTest(CreateTestDocument()).Build();
51+
Assert.IsFalse(d.HasDifferences());
52+
```
53+
54+
### Asserting an XPath Value
55+
56+
```csharp
57+
ISource source = Input.FromString("<foo>bar</foo>").Build();
58+
IXPathEngine xpath = new XPathEngine();
59+
IEnumerable<XmlNode> allMatches = xpath.SelectNodes("/foo", source);
60+
string content = xpath.evaluate("/foo/text()", source);
61+
```
62+
63+
### Validating a Document Against an XML Schema
64+
65+
66+
```csharp
67+
Validator v = Validator.ForLanguage(Languages.W3C_XML_SCHEMA_NS_URI);
68+
v.SchemaSources = new ISource[] {
69+
Input.FromUri("http://example.com/some.xsd").Build(),
70+
Input.FromFile("local.xsd").Build()
71+
};
72+
ValidationResult result = v.ValidateInstance(Input.FromDocument(CreateDocument()).Build());
73+
bool valid = result.Valid;
74+
IEnumerable<ValidationProblem> problems = result.Problems;
75+
```
76+
77+
## Additional Documentation
78+
79+
XMLUnit.NET is developed at
80+
[github](https://github.com/xmlunit/xmlunit.net). More documentation,
81+
releases and an issue tracker can be found there.
82+
83+
## Changelog
84+
85+
See the [Release
86+
Notes](https://github.com/xmlunit/xmlunit.net/blob/main/RELEASE_NOTES.md)
87+
at github.

src/main/net-core/XMLUnit.Core.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<frameworkAssembly assemblyName="System.Xml.Linq" />
1818
</frameworkAssemblies>
1919
<tags>xmlunit xml unit-testing test xmldiff</tags>
20+
<readme>docs\README.md</readme>
2021
</metadata>
2122
<files>
2223
<file src="..\..\..\build/NetFramework/bin/Release/xmlunit-core.dll" target="lib\net35"/>
@@ -25,5 +26,6 @@
2526
<file src="..\..\..\build/bin/Release/netstandard2.0/xmlunit-core.dll" target="lib\netstandard2.0"/>
2627
<file src="..\..\..\build/bin/Release/netstandard2.0/xmlunit-core.pdb" target="lib\netstandard2.0"/>
2728
<file src="..\..\..\build/bin/Release/netstandard2.0/xmlunit-core.xml" target="lib\netstandard2.0"/>
29+
<file src="..\..\docs/readmes/xmlunit-core/README.md" target="docs"/>
2830
</files>
2931
</package>

0 commit comments

Comments
 (0)