Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
authored and
unknown
committed
Dec 12, 2014
1 parent
9884775
commit bc6bff2
Showing
2 changed files
with
64 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Linq; | ||
using NUnit.Framework; | ||
using StructureMap.Graph; | ||
|
||
namespace StructureMap.Testing.Bugs | ||
{ | ||
[TestFixture] | ||
public class Bug_313 | ||
{ | ||
[Test] | ||
public void exclude_type_does_indeed_work() | ||
{ | ||
var container = new Container(_ => | ||
{ | ||
_.Scan(x => | ||
{ | ||
x.TheCallingAssembly(); | ||
x.AddAllTypesOf<IFoo>(); | ||
x.ExcludeType<Foo2>(); | ||
}); | ||
}); | ||
|
||
container.GetAllInstances<IFoo>() | ||
.Select(x => x.GetType()) | ||
.ShouldHaveTheSameElementsAs(typeof(Foo1), typeof(Foo3)); | ||
} | ||
|
||
[Test, Explicit("This test is invalid and will fail, included to demonstrate a usage problem")] | ||
public void demo_of_problem() | ||
{ | ||
var container = new Container(_ => | ||
{ | ||
_.Scan(x => | ||
{ | ||
x.TheCallingAssembly(); | ||
x.AddAllTypesOf<IFoo>(); | ||
x.ExcludeType<Foo2>(); | ||
}); | ||
_.Scan(x => | ||
{ | ||
x.TheCallingAssembly(); | ||
x.AddAllTypesOf<IFoo>(); | ||
x.ExcludeType<Foo1>(); | ||
}); | ||
}); | ||
|
||
// This will fail! | ||
container.GetAllInstances<IFoo>() | ||
.Select(x => x.GetType()) | ||
.ShouldHaveTheSameElementsAs(typeof(Foo3)); | ||
} | ||
|
||
public interface IFoo | ||
{ | ||
|
||
} | ||
|
||
public class Foo1 : IFoo { } | ||
public class Foo2 : IFoo { } | ||
public class Foo3 : IFoo { } | ||
} | ||
} |
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