Skip to content

Commit e234d91

Browse files
committed
readme for placeholders package
1 parent ec6720c commit e234d91

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
This package provides a way to simplify comparisons by using a control
7+
document with a simple expression language to compare against.
8+
9+
## Requirements
10+
11+
XMLUnit requires .NET Standard 2.0 (tested with .NET 8 rigt now) and
12+
should still support .NET Framework 3.5 and Mono.
13+
14+
The placeholders package only depends on XMLUnit.Core.
15+
16+
## Usage
17+
18+
More documentaion is available as part of
19+
the [user guide](https://github.com/xmlunit/user-guide/wiki).
20+
21+
If you are creating documents with a structure like
22+
23+
```xml
24+
<message>
25+
<id>12345</id>
26+
<content>Hello</content>
27+
</message>
28+
```
29+
30+
and can't predict the `id` inside your tests but still want to assert
31+
it is a number, using just the core library will require some custom
32+
code as a `IDifferenceEvaluator`
33+
34+
Using the placeholders package you can write a control document like
35+
36+
```xml
37+
<message>
38+
<id>${xmlunit.isNumber}</id>
39+
<content>Hello</content>
40+
</message>
41+
```
42+
43+
and run the test like
44+
45+
```csharp
46+
string control = <the above>;
47+
string test = <the program output>;
48+
Diff diff = DiffBuilder.Compare(control).WithTest(test)
49+
.WithDifferenceEvaluator(new PlaceholderDifferenceEvaluator()).build();
50+
Assert.IsFalse(d.HasDifferences());
51+
```
52+
53+
Currently the fillowing placeholders are defined:
54+
55+
* `${xmlunit.ignore}` to completely ignore the element
56+
* `${xmlunit.isNumber}`
57+
* `${xmlunit.matchesRegex()}` with regex parameter
58+
* `${xmlunit.isDateTime()}` with optional format parameter
59+
60+
## Additional Documentation
61+
62+
XMLUnit.NET is developed at
63+
[github](https://github.com/xmlunit/xmlunit.net). More documentation,
64+
releases and an issue tracker can be found there.
65+
66+
## Changelog
67+
68+
See the [Release
69+
Notes](https://github.com/xmlunit/xmlunit.net/blob/main/RELEASE_NOTES.md)
70+
at github.

src/main/net-placeholders/XMLUnit.Placeholders.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<frameworkAssembly assemblyName="System.Xml" />
2121
</frameworkAssemblies>
2222
<tags>xmlunit xml unit-testing test xmldiff</tags>
23+
<readme>docs\README.md</readme>
2324
</metadata>
2425
<files>
2526
<file src="..\..\..\build/NetFramework/bin/Release/xmlunit-placeholders.dll" target="lib\net35"/>
@@ -28,5 +29,6 @@
2829
<file src="..\..\..\build/bin/Release/netstandard2.0/xmlunit-placeholders.dll" target="lib\netstandard2.0"/>
2930
<file src="..\..\..\build/bin/Release/netstandard2.0/xmlunit-placeholders.pdb" target="lib\netstandard2.0"/>
3031
<file src="..\..\..\build/bin/Release/netstandard2.0/xmlunit-placeholders.xml" target="lib\netstandard2.0"/>
32+
<file src="..\..\doc/readmes/net-placeholders/README.md" target="docs"/>
3133
</files>
3234
</package>

0 commit comments

Comments
 (0)