Skip to content

Commit

Permalink
Added test for autofac#507 (AsClosedTypesOf does not register compone…
Browse files Browse the repository at this point in the history
…nt as non-generic interface)
  • Loading branch information
alexandrnikitin committed May 20, 2014
1 parent 2525657 commit fb248e7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@
<Compile Include="BComponent.cs" />
<Compile Include="A2Component.cs" />
<Compile Include="BModule.cs" />
<Compile Include="CloseCommand.cs" />
<Compile Include="CommandBase.cs" />
<Compile Include="DeleteCommand.cs" />
<Compile Include="DeleteCommandData.cs" />
<Compile Include="HasNestedFactoryDelegate.cs" />
<Compile Include="IAService.cs" />
<Compile Include="IBService.cs" />
<Compile Include="ICloseCommand.cs" />
<Compile Include="ICommand.cs" />
<Compile Include="Message.cs" />
<Compile Include="MetadataAttributeScanningScenario.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Autofac.Tests.Scenarios.ScannedAssembly
{
public class CloseCommand : ICloseCommand
{
public void Execute(object data)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Autofac.Tests.Scenarios.ScannedAssembly
{
public interface ICloseCommand : ICommand<object>
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ public void AsClosedTypesOfOpenGenericAbstractClassTypeProvidedClosingGenericTyp
Assert.That(c.Resolve<Message<string>>(), Is.TypeOf<StringMessage>());
}

[Test]
public void AsClosedTypesOfClosingInterfaceTypeRegistered()
{
var cb = new ContainerBuilder();
cb.RegisterAssemblyTypes(typeof(ICloseCommand).Assembly)
.AsClosedTypesOf(typeof(ICommand<>));
var c = cb.Build();

Assert.That(c.Resolve<ICloseCommand>(), Is.TypeOf<CloseCommand>());
}

[Test]
public void AsSelfExposesConcreteTypeAsService()
{
Expand Down

0 comments on commit fb248e7

Please sign in to comment.