Skip to content

Commit 9d3a3d5

Browse files
committed
Migrate tests to Xunit.Net 2.0
1 parent 07da01b commit 9d3a3d5

File tree

10 files changed

+40
-82
lines changed

10 files changed

+40
-82
lines changed

.nuget/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="xunit.runners" version="1.9.2" />
3+
<package id="xunit.runners" version="2.0.0-beta5-build2785" />
44
</packages>

CI/build.msbuild

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<DeployFolder>$(RootDir)\Build</DeployFolder>
77
</PropertyGroup>
88

9-
<UsingTask AssemblyFile="$(RootDir)\packages\xunit.runners.1.9.2\tools\xunit.runner.msbuild.dll"
9+
<UsingTask AssemblyFile="$(RootDir)\packages\xunit.runners.2.0.0-beta5-build2785\tools\xunit.runner.msbuild.dll"
1010
TaskName="Xunit.Runner.MSBuild.xunit" />
1111
<Target Name="Clean">
1212
<Message Text="Commit SHA = $(CommitSha)" />
@@ -37,7 +37,7 @@
3737
</Target>
3838

3939
<Target Name="Test" DependsOnTargets="Build">
40-
<xunit Assembly="$(TestBuildDir)/LibGit2Sharp.Tests.dll" Xml="$(DeployFolder)/Test-result.xml" />
40+
<xunit Assemblies="$(TestBuildDir)/LibGit2Sharp.Tests.dll" Xml="$(DeployFolder)/Test-result.xml" />
4141
</Target>
4242

4343
<Target Name="Deploy" DependsOnTargets="Test">

LibGit2Sharp.Tests/ConflictFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public void CanGetOriginalNamesOfRenameConflicts()
112112
}
113113
}
114114

115-
[Theory, PropertyData("ConflictData")]
115+
[Theory, MemberData("ConflictData")]
116116
public void CanRetrieveSingleConflictByPath(string filepath, string ancestorId, string ourId, string theirId)
117117
{
118118
using (var repo = new Repository(MergedTestRepoWorkingDirPath))

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileSta
157157
[InlineData("new_tracked_file.txt", FileStatus.Added, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
158158
[InlineData("modified_staged_file.txt", FileStatus.Staged, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
159159
[InlineData("modified_unstaged_file.txt", FileStatus.Modified, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
160-
public void MovingOverAnExistingFileThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
160+
public void MovingOverAnExistingFileThrows(string sourcePath, FileStatus sourceStatus, string[] destPaths)
161161
{
162162
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
163163
}
164164

165165
[Theory]
166166
[InlineData("new_untracked_file.txt", FileStatus.Untracked, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
167-
public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
167+
public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, FileStatus sourceStatus, string[] destPaths)
168168
{
169169
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
170170
}
@@ -173,7 +173,7 @@ public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, File
173173
[InlineData("deleted_unstaged_file.txt", FileStatus.Missing, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
174174
[InlineData("deleted_staged_file.txt", FileStatus.Removed, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
175175
[InlineData("i_dont_exist.txt", FileStatus.Nonexistent, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt", "deleted_unstaged_file.txt", "deleted_staged_file.txt", "i_dont_exist.txt" })]
176-
public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
176+
public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileStatus sourceStatus, string[] destPaths)
177177
{
178178
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
179179
}

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props')" />
34
<PropertyGroup>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,7 +11,7 @@
1011
<AppDesignerFolder>Properties</AppDesignerFolder>
1112
<RootNamespace>LibGit2Sharp.Tests</RootNamespace>
1213
<AssemblyName>LibGit2Sharp.Tests</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1415
<FileAlignment>512</FileAlignment>
1516
<TargetFrameworkProfile />
1617
</PropertyGroup>
@@ -22,6 +23,7 @@
2223
<DefineConstants>TRACE;DEBUG;NET40</DefineConstants>
2324
<ErrorReport>prompt</ErrorReport>
2425
<WarningLevel>4</WarningLevel>
26+
<Prefer32Bit>false</Prefer32Bit>
2527
</PropertyGroup>
2628
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2729
<DebugType>pdbonly</DebugType>
@@ -30,6 +32,7 @@
3032
<DefineConstants>TRACE</DefineConstants>
3133
<ErrorReport>prompt</ErrorReport>
3234
<WarningLevel>4</WarningLevel>
35+
<Prefer32Bit>false</Prefer32Bit>
3336
</PropertyGroup>
3437
<ItemGroup>
3538
<Reference Include="Moq, Version=4.2.1409.1722, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
@@ -39,14 +42,19 @@
3942
<Reference Include="System" />
4043
<Reference Include="System.Core" />
4144
<Reference Include="System.Xml" />
42-
<Reference Include="xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
43-
<SpecificVersion>False</SpecificVersion>
44-
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
45+
<Reference Include="xunit.abstractions">
46+
<HintPath>..\packages\xunit.abstractions.2.0.0-beta5-build2785\lib\net35\xunit.abstractions.dll</HintPath>
4547
</Reference>
46-
<Reference Include="xunit.extensions">
47-
<HintPath>..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll</HintPath>
48+
<Reference Include="xunit.assert">
49+
<HintPath>..\packages\xunit.assert.2.0.0-beta5-build2785\lib\portable-net45+aspnetcore50+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
4850
<Private>True</Private>
4951
</Reference>
52+
<Reference Include="xunit.core">
53+
<HintPath>..\packages\xunit.core.2.0.0-beta5-build2785\lib\portable-net45+aspnetcore50+win+wpa81+wp80+monotouch+monoandroid\xunit.core.dll</HintPath>
54+
</Reference>
55+
<Reference Include="xunit.execution, Version=2.0.0.2785, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
56+
<HintPath>..\packages\xunit.execution.2.0.0-beta5-build2785\lib\net45\xunit.execution.dll</HintPath>
57+
</Reference>
5058
</ItemGroup>
5159
<ItemGroup>
5260
<Compile Include="BlameFixture.cs" />
@@ -139,6 +147,12 @@
139147
<PreBuildEvent>
140148
</PreBuildEvent>
141149
</PropertyGroup>
150+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
151+
<PropertyGroup>
152+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
153+
</PropertyGroup>
154+
<Error Condition="!Exists('..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0-beta5-build2785\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.props'))" />
155+
</Target>
142156
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
143157
Other similar extension points exist, see Microsoft.Common.targets.
144158
<Target Name="BeforeBuild">

LibGit2Sharp.Tests/StageFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public void CanStageAnUnknownFileWithLaxUnmatchedExplicitPathsValidation(string
8181
Assert.Null(repo.Index[relativePath]);
8282
Assert.Equal(status, repo.RetrieveStatus(relativePath));
8383

84-
Assert.DoesNotThrow(() => repo.Stage(relativePath));
85-
Assert.DoesNotThrow(() => repo.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } }));
84+
repo.Stage(relativePath);
85+
repo.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } });
8686

8787
Assert.Equal(status, repo.RetrieveStatus(relativePath));
8888
}

LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -58,78 +58,16 @@
5858
//* portion of the software in compiled or object code form, you may
5959
//* only do so under a license that complies with this license.
6060
//**********************************************************************
61-
using System.Collections.Generic;
62-
using System.Linq;
63-
using System.Xml;
6461
using Xunit;
65-
using Xunit.Extensions;
66-
using Xunit.Sdk;
6762

6863
namespace LibGit2Sharp.Tests.TestHelpers
6964
{
7065
class SkippableFactAttribute : FactAttribute
7166
{
72-
protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
73-
{
74-
return base.EnumerateTestCommands(method).Select(SkippableTestCommand.Wrap(method));
75-
}
7667
}
7768

7869
class SkippableTheoryAttribute : TheoryAttribute
7970
{
80-
protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
81-
{
82-
return base.EnumerateTestCommands(method).Select(SkippableTestCommand.Wrap(method));
83-
}
84-
}
85-
86-
class SkippableTestCommand : ITestCommand
87-
{
88-
public static Func<ITestCommand, ITestCommand> Wrap(IMethodInfo method)
89-
{
90-
return c => new SkippableTestCommand(method, c);
91-
}
92-
93-
private readonly IMethodInfo method;
94-
private readonly ITestCommand inner;
95-
96-
private SkippableTestCommand(IMethodInfo method, ITestCommand inner)
97-
{
98-
this.method = method;
99-
this.inner = inner;
100-
}
101-
102-
public MethodResult Execute(object testClass)
103-
{
104-
try
105-
{
106-
return inner.Execute(testClass);
107-
}
108-
catch (SkipException e)
109-
{
110-
return new SkipResult(method, DisplayName, e.Reason);
111-
}
112-
}
113-
114-
public XmlNode ToStartXml()
115-
{
116-
return inner.ToStartXml();
117-
}
118-
119-
public string DisplayName
120-
{
121-
get { return inner.DisplayName; }
122-
}
123-
124-
public bool ShouldCreateInstance
125-
{
126-
get { return inner.ShouldCreateInstance; }
127-
}
128-
129-
public int Timeout
130-
{
131-
get { return inner.Timeout; }
132-
}
13371
}
13472

13573
class SkipException : Exception

LibGit2Sharp.Tests/UnstageFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void CanUnstageUnknownPathsWithLaxUnmatchedExplicitPathsValidation(string
106106
{
107107
Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));
108108

109-
Assert.DoesNotThrow(() => repo.Unstage(relativePath, new ExplicitPathsOptions() { ShouldFailOnUnmatchedPath = false }));
109+
repo.Unstage(relativePath, new ExplicitPathsOptions() { ShouldFailOnUnmatchedPath = false });
110110
Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));
111111
}
112112
}
@@ -182,8 +182,8 @@ public void CanUnstageUnknownPathsAgainstAnOrphanedHeadWithLaxUnmatchedExplicitP
182182

183183
Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));
184184

185-
Assert.DoesNotThrow(() => repo.Unstage(relativePath));
186-
Assert.DoesNotThrow(() => repo.Unstage(relativePath, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false }));
185+
repo.Unstage(relativePath);
186+
repo.Unstage(relativePath, new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false });
187187
Assert.Equal(currentStatus, repo.RetrieveStatus(relativePath));
188188
}
189189
}

LibGit2Sharp.Tests/app.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
5+
</startup>
36
<runtime>
47
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
58
<dependentAssembly>

LibGit2Sharp.Tests/packages.config

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Moq" version="4.2.1409.1722" targetFramework="net40" />
4-
<package id="xunit" version="1.9.2" targetFramework="net40" />
5-
<package id="xunit.extensions" version="1.9.2" targetFramework="net40" />
4+
<package id="xunit" version="2.0.0-beta5-build2785" targetFramework="net45" />
5+
<package id="xunit.abstractions" version="2.0.0-beta5-build2785" targetFramework="net45" />
6+
<package id="xunit.assert" version="2.0.0-beta5-build2785" targetFramework="net45" />
7+
<package id="xunit.core" version="2.0.0-beta5-build2785" targetFramework="net45" />
8+
<package id="xunit.execution" version="2.0.0-beta5-build2785" targetFramework="net45" />
69
</packages>

0 commit comments

Comments
 (0)