Created
July 30, 2021 06:02
-
-
Save alistairjevans/6cf270a7d87eca69d37a2c538dc9749e to your computer and use it in GitHub Desktop.
CovariantTestFailure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Xunit; | |
namespace Autofac.Test.Features.OpenGenerics | |
{ | |
public class OpenGenericCovariantTests | |
{ | |
private interface INotificationHandler<TNotification> | |
{ | |
} | |
private interface INotification | |
{ | |
} | |
private class MyNotification : INotification | |
{ | |
} | |
private class Handler : INotificationHandler<INotification> | |
{ | |
} | |
[Fact] | |
public void CanResolveCovariantOpenGeneric() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterType<Handler>().As<INotificationHandler<INotification>>(); | |
var container = builder.Build(); | |
// Nope... | |
container.Resolve<INotificationHandler<MyNotification>>(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment