Skip to content

Commit 520ef6f

Browse files
committed
Upgrade to xUnit 2.0
1 parent a07186e commit 520ef6f

10 files changed

+35
-92
lines changed

CI/travis.osx.install.deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -ev
33

4-
MONO_VER=3.6.0
4+
MONO_VER=4.0.2
55

66
brew update
77
which cmake || brew install cmake

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public static IEnumerable<object[]> ConfigAccessors
382382
}
383383
}
384384

385-
[Theory, PropertyData("ConfigAccessors")]
385+
[Theory, MemberData("ConfigAccessors")]
386386
public void CanAccessConfigurationWithoutARepository(Func<string, string> localConfigurationPathProvider)
387387
{
388388
var path = SandboxStandardTestRepoGitDir();

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
var path = SandboxMergedTestRepo();

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileSta
162162
[InlineData("new_tracked_file.txt", FileStatus.NewInIndex, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
163163
[InlineData("modified_staged_file.txt", FileStatus.ModifiedInIndex, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
164164
[InlineData("modified_unstaged_file.txt", FileStatus.ModifiedInWorkdir, new[] { "README", "new_tracked_file.txt", "modified_staged_file.txt", "modified_unstaged_file.txt", "new_untracked_file.txt" })]
165-
public void MovingOverAnExistingFileThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
165+
public void MovingOverAnExistingFileThrows(string sourcePath, FileStatus sourceStatus, string[] destPaths)
166166
{
167167
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
168168
}
169169

170170
[Theory]
171171
[InlineData("new_untracked_file.txt", FileStatus.NewInWorkdir, 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" })]
172-
public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
172+
public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, FileStatus sourceStatus, string[] destPaths)
173173
{
174174
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
175175
}
@@ -178,7 +178,7 @@ public void MovingAFileWichIsNotUnderSourceControlThrows(string sourcePath, File
178178
[InlineData("deleted_unstaged_file.txt", FileStatus.DeletedFromWorkdir, 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" })]
179179
[InlineData("deleted_staged_file.txt", FileStatus.DeletedFromIndex, 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" })]
180180
[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" })]
181-
public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileStatus sourceStatus, IEnumerable<string> destPaths)
181+
public void MovingAFileNotInTheWorkingDirectoryThrows(string sourcePath, FileStatus sourceStatus, string[] destPaths)
182182
{
183183
InvalidMoveUseCases(sourcePath, sourceStatus, destPaths);
184184
}

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" />
4+
<Import Project="..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
67
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -11,7 +12,7 @@
1112
<AppDesignerFolder>Properties</AppDesignerFolder>
1213
<RootNamespace>LibGit2Sharp.Tests</RootNamespace>
1314
<AssemblyName>LibGit2Sharp.Tests</AssemblyName>
14-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
15+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1516
<FileAlignment>512</FileAlignment>
1617
<TargetFrameworkProfile />
1718
</PropertyGroup>
@@ -41,12 +42,17 @@
4142
<Reference Include="System" />
4243
<Reference Include="System.Core" />
4344
<Reference Include="System.Xml" />
44-
<Reference Include="xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
45-
<SpecificVersion>False</SpecificVersion>
46-
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
45+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
46+
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
47+
<Private>True</Private>
4748
</Reference>
48-
<Reference Include="xunit.extensions">
49-
<HintPath>..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll</HintPath>
49+
<Reference Include="xunit.assert, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
50+
<HintPath>..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath>
51+
<Private>True</Private>
52+
</Reference>
53+
<Reference Include="xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
54+
<HintPath>..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath>
55+
<Private>True</Private>
5056
</Reference>
5157
</ItemGroup>
5258
<ItemGroup>
@@ -157,6 +163,7 @@
157163
<PropertyGroup>
158164
<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>
159165
</PropertyGroup>
166+
<Error Condition="!Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
160167
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props'))" />
161168
</Target>
162169
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

LibGit2Sharp.Tests/StageFixture.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public void CanStageAnUnknownFileWithLaxUnmatchedExplicitPathsValidation(string
8383
Assert.Null(repo.Index[relativePath]);
8484
Assert.Equal(status, repo.RetrieveStatus(relativePath));
8585

86-
Assert.DoesNotThrow(() => repo.Stage(relativePath));
87-
Assert.DoesNotThrow(() => repo.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } }));
86+
repo.Stage(relativePath);
87+
repo.Stage(relativePath, new StageOptions { ExplicitPathsOptions = new ExplicitPathsOptions { ShouldFailOnUnmatchedPath = false } });
8888

8989
Assert.Equal(status, repo.RetrieveStatus(relativePath));
9090
}
@@ -387,8 +387,7 @@ public void CanSuccessfullyStageTheContentOfAModifiedFileOfTheSameSizeWithinTheS
387387

388388
repo.Stage("test.txt");
389389

390-
Assert.DoesNotThrow(() => repo.Commit(
391-
"Commit", Constants.Signature, Constants.Signature));
390+
repo.Commit("Commit", Constants.Signature, Constants.Signature);
392391
}
393392
}
394393
}

LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Xml;
52
using Xunit;
6-
using Xunit.Extensions;
7-
using Xunit.Sdk;
83
//**********************************************************************
94
//* This file is based on the DynamicSkipExample.cs in xUnit which is
105
//* provided under the following Ms-PL license:
@@ -69,68 +64,12 @@ 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-
}
8471
}
8572

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-
}
133-
}
13473

13574
class SkipException : Exception
13675
{

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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<runtime>
4-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
5-
<dependentAssembly>
6-
<assemblyIdentity name="xunit" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
7-
<bindingRedirect oldVersion="0.0.0.0-1.9.2.1705" newVersion="1.9.2.1705" />
8-
</dependentAssembly>
9-
</assemblyBinding>
10-
</runtime>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
5+
</startup>
116
</configuration>

LibGit2Sharp.Tests/packages.config

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Moq" version="4.2.1507.0118" targetFramework="net40" />
4-
<package id="xunit" version="1.9.2" targetFramework="net40" />
5-
<package id="xunit.extensions" version="1.9.2" targetFramework="net40" />
6-
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net40" />
3+
<package id="Moq" version="4.2.1507.0118" targetFramework="net45" />
4+
<package id="xunit" version="2.0.0" targetFramework="net45" />
5+
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
6+
<package id="xunit.assert" version="2.0.0" targetFramework="net45" />
7+
<package id="xunit.core" version="2.0.0" targetFramework="net45" />
8+
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net45" />
9+
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net45" />
710
</packages>

0 commit comments

Comments
 (0)