Skip to content

Commit

Permalink
Added complex generic types #1
Browse files Browse the repository at this point in the history
These are excluded from tests at the moment as the framework cannot
handle them.
  • Loading branch information
JSkimming committed Jul 29, 2013
1 parent 86ab85c commit f6ed747
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public async Task MixedStringValue(MethodData method)
}

[Theory, RequiresArgNullExAutoMoq(typeof(InterfaceGenericMethods))]
[Include(Type = typeof(InterfaceGenericMethods))]
[Include(
ExclusionType = ExclusionType.All,
Type = typeof(InterfaceGenericMethods),
Expand All @@ -58,7 +57,6 @@ public async Task InterfaceClassValue(MethodData method)
}

[Theory, RequiresArgNullExAutoMoq(typeof(InterfaceGenericMethods))]
[Include(Type = typeof(InterfaceGenericMethods))]
[Include(
ExclusionType = ExclusionType.All,
Type = typeof(InterfaceGenericMethods),
Expand All @@ -70,5 +68,18 @@ public async Task InterfaceStringValue(MethodData method)

Assert.True(InterfaceGenericMethods.StringValueTested);
}

[Theory, RequiresArgNullExAutoMoq(typeof(ComplexGenericMethods))]
[Include(
ExclusionType = ExclusionType.Parameters,
Type = typeof(ComplexGenericMethods),
Method = "NonGenericMethod",
Parameter = "value")]
public async Task ComplexNonGeneric(MethodData method)
{
await method.Execute();

Assert.True(ComplexGenericMethods.NonGenericTested);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Reflection;
using AutoTest.ArgNullEx;
using AutoTest.ArgNullEx.Xunit;
using AutoTest.ExampleLibrary.Issues.Issue001;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoMoq;

Expand Down Expand Up @@ -40,7 +41,8 @@ private static IArgumentNullExceptionFixture CreateFixture(Assembly assemblyUnde
// Don't need to create complex graphs, just need objects.
fixture.OmitAutoProperties = true;

return new ArgumentNullExceptionFixture(assemblyUnderTest, fixture);
return new ArgumentNullExceptionFixture(assemblyUnderTest, fixture)
.ExcludeType(typeof(ComplexGenericMethods)); // Exclude until it can be tested.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<Link>Properties\AssemblyInfoCommon.cs</Link>
</Compile>
<Compile Include="Class1.cs" />
<Compile Include="Issues\Issue001\ComplexGenericMethods.cs" />
<Compile Include="Issues\Issue001\InterfaceGenericMethods.cs" />
<Compile Include="Issues\Issue001\MixedGenericMethods.cs" />
<Compile Include="Issues\Issue001\SimpleGenericMethods.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace AutoTest.ExampleLibrary.Issues.Issue001
{
using System;

public static class ComplexGenericMethods
{
/// <summary>
/// Gets a value indicating if the <see cref="NonGenericMethod"/> value parameter has been tested.
/// </summary>
public static bool NonGenericTested { get; private set; }

public interface ITest1
{
string String1 { get; set; }
}

public interface ITest2
{
string String2 { get; set; }
}

public static void NonGenericMethod(string value)
{
NonGenericTested = false;
if (value == null)
{
NonGenericTested = true;
throw new ArgumentNullException("value");
}

throw new Exception("Shouldn't ever get here.");
}

public static void GenericClassMethod<TClass>(TClass classValue, string stringValue)
where TClass : class, ITest1, ITest2
{
throw new Exception("Shouldn't ever get here.");
}

public static void GenericExceptionMethod<TException>(TException classValue, string stringValue)
where TException : Exception, ITest1, ITest2
{
throw new Exception("Shouldn't ever get here.");
}

public static void GenericStructMethod<TStruct>(TStruct classValue, string stringValue)
where TStruct : struct, ITest1, ITest2
{
throw new Exception("Shouldn't ever get here.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface ITest2
public static void GenericMethod<TClass>(TClass classValue, string stringValue)
where TClass : ITest1, ITest2
{
ClassValueTested = false;
StringValueTested = ClassValueTested = false;

if (classValue == null)
{
Expand Down

0 comments on commit f6ed747

Please sign in to comment.