Skip to content

Commit

Permalink
Failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogard committed Jan 26, 2015
1 parent af04c02 commit da45faf
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/StructureMap.Testing/Bugs/GenericVarianceResolution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
namespace StructureMap.Testing.Bugs
{
using System.Linq;
using NUnit.Framework;
using StructureMap.Graph;

public interface INotificationHandler<in TNotification>
{
void Handle(TNotification notification);
}

public class BaseNotificationHandler : INotificationHandler<object>
{
public void Handle(object notification)
{

}
}

public class OpenNotificationHandler<TNotification> : INotificationHandler<TNotification>
{
public void Handle(TNotification notification)
{

}
}

public class Notification { }

public class ConcreteNotificationHandler : INotificationHandler<Notification>
{
public void Handle(Notification notification)
{

}
}

[TestFixture]
public class GenericVarianceResolution
{
[Test]
public void RegisterMultipleHandlersOfSameInterface()
{
var container = new Container(x =>
{
x.Scan(s =>
{
s.TheCallingAssembly();
s.AddAllTypesOf(typeof (INotificationHandler<>));
});
});

var handlers = container.GetAllInstances<INotificationHandler<Notification>>();

handlers.Single(h => h.GetType() == typeof (ConcreteNotificationHandler));
//handlers.Single(h => h.GetType() == typeof(OpenNotificationHandler<Notification>));
handlers.Single(h => h.GetType() == typeof(BaseNotificationHandler));

handlers.Count().ShouldEqual(3);
}
}
}
1 change: 1 addition & 0 deletions src/StructureMap.Testing/StructureMap.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
<Compile Include="Bugs\EnumerableShouldGetAllValuesTester.cs" />
<Compile Include="Bugs\Exception_Within_Exception_Bug.cs" />
<Compile Include="Bugs\FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs" />
<Compile Include="Bugs\GenericVarianceResolution.cs" />
<Compile Include="Bugs\InjectByFuncWithNoPublicConstructors.cs" />
<Compile Include="Bugs\Jimmys_silly_open_generics_bug.cs" />
<Compile Include="Bugs\LambdaCreatesNullBugTester.cs" />
Expand Down

0 comments on commit da45faf

Please sign in to comment.