forked from DarthFubuMVC/fubumvc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the FubuRegistry.WithTypes() method
- Loading branch information
1 parent
d1fae65
commit a316e6a
Showing
4 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using FubuMVC.Core; | ||
using FubuMVC.Core.Registration.ObjectGraph; | ||
using NUnit.Framework; | ||
using FubuCore; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FubuTestingSupport; | ||
|
||
namespace FubuMVC.Tests | ||
{ | ||
[TestFixture] | ||
public class FubuRegistryWithTypesTester | ||
{ | ||
|
||
[Test] | ||
public void smoke_test_the_with_types() | ||
{ | ||
var registry = new FubuRegistry(); | ||
registry.Applies.ToThisAssembly(); | ||
registry.WithTypes(types => | ||
{ | ||
types.TypesMatching(x => x.IsConcreteTypeOf<MyInterface>()).Each(type => | ||
{ | ||
registry.Services(s => s.AddService(typeof(MyInterface), new ObjectDef(type))); | ||
}); | ||
}); | ||
|
||
registry.BuildGraph().Services.ServicesFor<MyInterface>() | ||
.Single().Type.ShouldEqual(typeof (MyConcreteClass)); | ||
} | ||
|
||
public interface MyInterface{} | ||
|
||
public class MyConcreteClass : MyInterface | ||
{ | ||
|
||
} | ||
} | ||
} |