Skip to content

Commit 51a441d

Browse files
committed
and .NET examples
1 parent 4a892f1 commit 51a441d

8 files changed

+228
-1
lines changed

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
*.build text
2+
*.cs text diff=csharp
3+
*.csproj text
4+
*.dll binary
15
*.dtd text
26
*.html text diff=html
37
*.java text diff=java
48
*.md text
9+
*.nuspec text
510
*.rng text
611
*.rngc text
712
*.sh eol=lf
13+
*.shfbproj text
14+
*.sln text
15+
*.snk binary
816
*.xml text
917
*.xsd text
1018
*.xsl text

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ target
33
.settings
44
.classpath
55
.project
6-
6+
packages
7+
obj

examples/net/UserguideExamples.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.31101.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFCB}") = "XMLUnit.UserguideExamples", "src\XMLUnit.UserguideExamples.csproj", "{97960A9C-7E2B-4548-90BD-31105C54E192}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{97960A9C-7E2B-4548-90BD-31105C54E192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{97960A9C-7E2B-4548-90BD-31105C54E192}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{97960A9C-7E2B-4548-90BD-31105C54E192}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{97960A9C-7E2B-4548-90BD-31105C54E192}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

examples/net/src/AssemblyInfo.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
This file is licensed to You under the Apache License, Version 2.0
3+
(the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
using System.Reflection;
15+
using System.Runtime.CompilerServices;
16+
17+
[assembly: AssemblyProduct("XMLUnit.NET UserGuide Examples")]
18+
[assembly: AssemblyTitleAttribute("XMLUnit UserGuide Examples")]
19+
[assembly: AssemblyDescription("UserGuide Examples of XMLUnit for .NET")]
20+
[assembly: AssemblyVersion("2.0.0")]
21+
[assembly: AssemblyInformationalVersion("2.0.0")]
22+
[assembly: AssemblyCompany("XMLUnit Contributors")]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
This file is licensed to You under the Apache License, Version 2.0
3+
(the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
using System;
16+
using System.Xml;
17+
using Org.XmlUnit.Diff;
18+
19+
namespace Org.XmlUnit.UserguideExamples {
20+
21+
public class IgnoreAttributeDifferenceEvaluator {
22+
private string attributeName;
23+
24+
public IgnoreAttributeDifferenceEvaluator(string attributeName) {
25+
this.attributeName = attributeName;
26+
}
27+
28+
public ComparisonResult Evaluate(Comparison comparison, ComparisonResult outcome) {
29+
if (outcome == ComparisonResult.EQUAL) return outcome; // only evaluate differences.
30+
XmlNode controlNode = comparison.ControlDetails.Target;
31+
XmlAttribute attr = controlNode as XmlAttribute;
32+
if (attr != null) {
33+
if (attr.Name == attributeName) {
34+
return ComparisonResult.SIMILAR; // will evaluate this difference as similar
35+
}
36+
}
37+
return outcome;
38+
}
39+
}
40+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
This file is licensed to You under the Apache License, Version 2.0
3+
(the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
using System;
16+
using NUnit.Framework;
17+
using Org.XmlUnit.Builder;
18+
19+
namespace Org.XmlUnit.UserguideExamples {
20+
21+
public class IgnoreAttributeDifferenceEvaluatorTest {
22+
23+
[Test]
24+
public void TestUserguideExample() {
25+
string control = "<a><b attr=\"abc\"></b></a>";
26+
string test = "<a><b attr=\"xyz\"></b></a>";
27+
28+
var myDiff = DiffBuilder.Compare(control).WithTest(test)
29+
.WithDifferenceEvaluator(new IgnoreAttributeDifferenceEvaluator("attr").Evaluate)
30+
.CheckForSimilar()
31+
.Build();
32+
33+
Assert.IsFalse(myDiff.HasDifferences(), myDiff.ToString());
34+
}
35+
}
36+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
This file is licensed to You under the Apache License, Version 2.0
4+
(the "License"); you may not use this file except in compliance with
5+
the License. You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
-->
15+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
16+
<PropertyGroup>
17+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
18+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
19+
<ProjectGuid>{97960A9C-7E2B-4548-90BD-31105C54E192}</ProjectGuid>
20+
<OutputType>Library</OutputType>
21+
<NoStandardLibraries>false</NoStandardLibraries>
22+
<AssemblyName>XMLUnit.UserguideExamples</AssemblyName>
23+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
24+
<FileAlignment>512</FileAlignment>
25+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
26+
<RestorePackages>true</RestorePackages>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
29+
<DebugSymbols>true</DebugSymbols>
30+
<DebugType>full</DebugType>
31+
<Optimize>false</Optimize>
32+
<OutputPath>..\target\bin\Debug</OutputPath>
33+
<DefineConstants>DEBUG;TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
<DocumentationFile>..\target\bin\Debug\XMLUnit.UserguideExamples.XML</DocumentationFile>
37+
</PropertyGroup>
38+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
39+
<DebugType>pdbonly</DebugType>
40+
<Optimize>true</Optimize>
41+
<OutputPath>..\target\bin\Release</OutputPath>
42+
<DefineConstants>TRACE</DefineConstants>
43+
<ErrorReport>prompt</ErrorReport>
44+
<WarningLevel>4</WarningLevel>
45+
</PropertyGroup>
46+
<PropertyGroup>
47+
<SignAssembly>false</SignAssembly>
48+
</PropertyGroup>
49+
<PropertyGroup>
50+
<RootNamespace>Org.XmlUnit.UserguideExamples</RootNamespace>
51+
</PropertyGroup>
52+
<ItemGroup>
53+
<Reference Include="nunit.framework, Version=3.0.5813.39033, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
54+
<HintPath>..\packages\NUnit.3.0.1\lib\net20\nunit.framework.dll</HintPath>
55+
<Private>True</Private>
56+
</Reference>
57+
<Reference Include="System" />
58+
<Reference Include="System.Core" />
59+
<Reference Include="System.Xml" />
60+
<Reference Include="System.Xml.Linq" />
61+
<Reference Include="xmlunit-core.dll">
62+
<HintPath>..\packages\XmlUnit.Core.2.0.0-alpha-03\lib\net35\xmlunit-core.dll</HintPath>
63+
<Private>True</Private>
64+
</Reference>
65+
</ItemGroup>
66+
<ItemGroup>
67+
<Compile Include="AssemblyInfo.cs" />
68+
<Compile Include="Diff\IgnoreAttributeDifferenceEvaluator.cs" />
69+
<Compile Include="Diff\IgnoreAttributeDifferenceEvaluatorTest.cs" />
70+
</ItemGroup>
71+
<ItemGroup>
72+
<None Include="packages.config" />
73+
</ItemGroup>
74+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
75+
<ProjectExtensions>
76+
<VisualStudio AllowExistingFolder="true" />
77+
</ProjectExtensions>
78+
<PropertyGroup Condition=" '$(OS)' != 'Unix' ">
79+
<NunitCommand>"$(SolutionDir)packages\NUnit.Console.3.0.1\tools\nunit3-console.exe" "$(AssemblyName).dll" --config=$(Configuration) --work=..\target\test-results\ --result=XMLUnit.UserguideExamples.Results.xml --framework=net-3.5 --process=Single</NunitCommand>
80+
</PropertyGroup>
81+
<PropertyGroup Condition=" '$(OS)' == 'Unix' ">
82+
<NunitCommand>mono "$(SolutionDir)packages/NUnit.Console.3.0.1/tools/nunit3-console.exe" "$(AssemblyName).dll" --config=$(Configuration) --work=../target/test-results --result=XMLUnit.UserguideExamples.Results.xml --process=Single</NunitCommand>
83+
</PropertyGroup>
84+
<Target Name="RunUnitTest">
85+
<MakeDir Directories="..\target\test-results" />
86+
<Exec Command="$(NunitCommand)" WorkingDirectory="$(OutputPath)" />
87+
</Target>
88+
<Target Name="AfterBuild" DependsOnTargets="RunUnitTest">
89+
</Target>
90+
</Project>

examples/net/src/packages.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="NUnit" version="3.0.1" targetFramework="net35" />
4+
<package id="NUnit.Console" version="3.0.1" targetFramework="net35" />
5+
<package id="NUnitTestAdapter" version="2.0.0" targetFramework="net35" />
6+
<package id="NUnit" version="3.0.1" targetFramework="net35" />
7+
<package id="XmlUnit.Core" version="2.0.0-alpha-03" targetFramework="net35" />
8+
</packages>

0 commit comments

Comments
 (0)