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:
authorKeith Dahlby <dahlbyk@gmail.com>2015-06-22 17:13:41 +0300
committernulltoken <emeric.fermas@gmail.com>2015-06-22 18:29:41 +0300
commit9ab380596487686ff2b89e35e5f6520cece3c008 (patch)
tree943f822c5b9aa36f5f2cf19e53b8bfd85eacb198
parent1cba9e4759fa3beae2b5af6c8b1e7e63fada2338 (diff)
Attempt to create mockable instances
-rw-r--r--LibGit2Sharp.Tests/MetaFixture.cs25
1 files changed, 24 insertions, 1 deletions
diff --git a/LibGit2Sharp.Tests/MetaFixture.cs b/LibGit2Sharp.Tests/MetaFixture.cs
index 86ecdf3c..3d0a4898 100644
--- a/LibGit2Sharp.Tests/MetaFixture.cs
+++ b/LibGit2Sharp.Tests/MetaFixture.cs
@@ -9,6 +9,7 @@ using System.Text;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
+using Moq;
namespace LibGit2Sharp.Tests
{
@@ -107,6 +108,28 @@ namespace LibGit2Sharp.Tests
{
nonTestableTypes.Add(type, new List<string>());
}
+
+ if (type.IsAbstract)
+ {
+ continue;
+ }
+
+ try
+ {
+ if (type.ContainsGenericParameters)
+ {
+ var constructType = type.MakeGenericType(Enumerable.Repeat(typeof(object), type.GetGenericArguments().Length).ToArray());
+ Activator.CreateInstance(constructType, true);
+ }
+ else
+ {
+ Activator.CreateInstance(type, true);
+ }
+ }
+ catch (Exception ex)
+ {
+ nonTestableTypes.Add(type, new List<string>());
+ }
}
if (nonTestableTypes.Any())
@@ -246,7 +269,7 @@ namespace LibGit2Sharp.Tests
var nonVirtualGetEnumeratorMethods = Assembly.GetAssembly(typeof(IRepository))
.GetExportedTypes()
.Where(t =>
- t.Namespace == typeof (IRepository).Namespace &&
+ t.Namespace == typeof(IRepository).Namespace &&
!t.IsSealed &&
!t.IsAbstract &&
t.GetInterfaces().Any(i => i.IsAssignableFrom(typeof(IEnumerable<>))))