Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'LibGit2Sharp.Tests/TestHelpers')
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs26
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs9
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/SkipException.cs14
-rw-r--r--LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs31
4 files changed, 62 insertions, 18 deletions
diff --git a/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs b/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs
index c8fe140d..a501d2fd 100644
--- a/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs
@@ -1,5 +1,5 @@
using System;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests.TestHelpers
{
@@ -7,46 +7,46 @@ namespace LibGit2Sharp.Tests.TestHelpers
{
public static void ShouldBeAboutEqualTo(this DateTimeOffset expected, DateTimeOffset current)
{
- Assert.AreEqual(expected.Date, current.Date);
- Assert.AreEqual(expected.Offset, current.Offset);
- Assert.AreEqual(expected.Hour, current.Hour);
- Assert.AreEqual(expected.Minute, current.Minute);
- Assert.AreEqual(expected.Second, current.Second);
+ Assert.Equal(expected.Date, current.Date);
+ Assert.Equal(expected.Offset, current.Offset);
+ Assert.Equal(expected.Hour, current.Hour);
+ Assert.Equal(expected.Minute, current.Minute);
+ Assert.Equal(expected.Second, current.Second);
}
public static void ShouldBeFalse(this bool currentObject)
{
- Assert.IsFalse(currentObject);
+ Assert.False(currentObject);
}
public static void ShouldBeNull(this object currentObject)
{
- Assert.IsNull(currentObject);
+ Assert.Null(currentObject);
}
public static void ShouldBeTrue(this bool currentObject)
{
- Assert.IsTrue(currentObject);
+ Assert.True(currentObject);
}
public static void ShouldEqual(this object compareFrom, object compareTo)
{
- Assert.AreEqual(compareTo, compareFrom);
+ Assert.Equal(compareTo, compareFrom);
}
public static void ShouldEqual<T>(this T compareFrom, T compareTo)
{
- Assert.AreEqual(compareTo, compareFrom);
+ Assert.Equal(compareTo, compareFrom);
}
public static void ShouldNotBeNull(this object currentObject)
{
- Assert.IsNotNull(currentObject);
+ Assert.NotNull(currentObject);
}
public static void ShouldNotEqual(this object compareFrom, object compareTo)
{
- Assert.AreNotEqual(compareTo, compareFrom);
+ Assert.NotEqual(compareTo, compareFrom);
}
}
}
diff --git a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
index 08b5ba54..5a45fde5 100644
--- a/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
+++ b/LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs
@@ -1,11 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
-using NUnit.Framework;
+using Xunit;
namespace LibGit2Sharp.Tests.TestHelpers
{
- public class BaseFixture : IPostTestDirectoryRemover
+ public class BaseFixture : IPostTestDirectoryRemover, IDisposable
{
private readonly List<string> directories = new List<string>();
@@ -78,8 +78,7 @@ namespace LibGit2Sharp.Tests.TestHelpers
directories.Add(directoryPath);
}
- [TestFixtureTearDown]
- public void Cleanup()
+ public void Dispose()
{
foreach (string directory in directories)
{
@@ -94,7 +93,7 @@ namespace LibGit2Sharp.Tests.TestHelpers
return;
}
- Assert.Inconclusive(message);
+ throw new SkipException(message);
}
}
}
diff --git a/LibGit2Sharp.Tests/TestHelpers/SkipException.cs b/LibGit2Sharp.Tests/TestHelpers/SkipException.cs
new file mode 100644
index 00000000..f1df39d9
--- /dev/null
+++ b/LibGit2Sharp.Tests/TestHelpers/SkipException.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace LibGit2Sharp.Tests.TestHelpers
+{
+ class SkipException : Exception
+ {
+ public SkipException(string reason)
+ {
+ Reason = reason;
+ }
+
+ public string Reason { get; set; }
+ }
+} \ No newline at end of file
diff --git a/LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs b/LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs
new file mode 100644
index 00000000..4cd6d7a8
--- /dev/null
+++ b/LibGit2Sharp.Tests/TestHelpers/SkippableFactAttribute.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+using Xunit;
+using Xunit.Sdk;
+
+namespace LibGit2Sharp.Tests.TestHelpers
+{
+ class SkippableFactAttribute : FactAttribute
+ {
+ protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
+ {
+ yield return new SkippableTestCommand(method);
+ }
+
+ class SkippableTestCommand : FactCommand
+ {
+ public SkippableTestCommand(IMethodInfo method) : base(method) { }
+
+ public override MethodResult Execute(object testClass)
+ {
+ try
+ {
+ return base.Execute(testClass);
+ }
+ catch (SkipException e)
+ {
+ return new SkipResult(testMethod, DisplayName, e.Reason);
+ }
+ }
+ }
+ }
+} \ No newline at end of file