-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring TypeDiscoverer a bit to accommodate new needs + changing …
…signatures Basically we are going to need to be able to find types from any enumerable of types. TypeDiscoverer had a bunch of this functionality we wanted but coupled together with how it wants to do things. Extracting out the finding of types part into its own ITypeFinder enables us to reuse the finding bits. Worth mentioning is that all signatures returning arrays of Type are now returning IEnumerable<Type> instead. This affected some implementations!
- Loading branch information
Showing
27 changed files
with
452 additions
and
161 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
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
15 changes: 0 additions & 15 deletions
15
...ypeDiscoverer/when_finding_types_with_multiple_implementations_but_asking_for_a_single.cs
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
namespace Bifrost.Specs.Execution.for_TypeFinder | ||
{ | ||
public interface ISingle | ||
{ | ||
|
||
} | ||
|
||
public class Single : ISingle | ||
{ | ||
|
||
} | ||
|
||
public interface IMultiple | ||
{ | ||
|
||
} | ||
|
||
public class FirstMultiple : IMultiple | ||
{ | ||
|
||
} | ||
|
||
public class SecondMultiple : IMultiple | ||
{ | ||
|
||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Source/Bifrost.Specs/Execution/for_TypeFinder/given/a_type_finder.cs
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,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Bifrost.Execution; | ||
using Machine.Specifications; | ||
|
||
namespace Bifrost.Specs.Execution.for_TypeFinder.given | ||
{ | ||
public class a_type_finder | ||
{ | ||
protected static TypeFinder type_finder; | ||
protected static IEnumerable<Type> types; | ||
|
||
Establish context = () => | ||
{ | ||
types = new[] { | ||
typeof(ISingle), | ||
typeof(Single), | ||
typeof(IMultiple), | ||
typeof(FirstMultiple), | ||
typeof(SecondMultiple) | ||
}; | ||
type_finder = new TypeFinder(); | ||
}; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...e/Bifrost.Specs/Execution/for_TypeFinder/when_finding_type_by_name_that_does_not_exist.cs
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,16 @@ | ||
using System; | ||
using Bifrost.Execution; | ||
using Machine.Specifications; | ||
|
||
namespace Bifrost.Specs.Execution.for_TypeFinder | ||
{ | ||
[Subject(typeof(TypeFinder))] | ||
public class when_finding_type_by_name_that_does_not_exist : given.a_type_finder | ||
{ | ||
static Exception exception; | ||
|
||
Because of = () => exception = Catch.Exception(() => type_finder.FindTypeByFullName(types, typeof(Single).FullName + "Blah")); | ||
|
||
It should_be_throw_unable_to_resolve_type_by_name = () => exception.ShouldBeOfExactType<UnableToResolveTypeByName>(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Source/Bifrost.Specs/Execution/for_TypeFinder/when_finding_type_by_name_that_exists.cs
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,17 @@ | ||
using System; | ||
using Bifrost.Execution; | ||
using Machine.Specifications; | ||
|
||
namespace Bifrost.Specs.Execution.for_TypeFinder | ||
{ | ||
[Subject(typeof(TypeFinder))] | ||
public class when_finding_type_by_name_that_exists : given.a_type_finder | ||
{ | ||
static Type type_found; | ||
|
||
Because of = () => type_found = type_finder.FindTypeByFullName(types, typeof(Single).FullName); | ||
|
||
It should_not_return_null = () => type_found.ShouldNotBeNull(); | ||
It should_return_the_correct_type = () => type_found.ShouldEqual(typeof(Single)); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ifrost.Specs/Execution/for_TypeFinder/when_finding_types_with_multiple_implementations.cs
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,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Bifrost.Execution; | ||
using Machine.Specifications; | ||
|
||
namespace Bifrost.Specs.Execution.for_TypeFinder | ||
{ | ||
[Subject(typeof(TypeFinder))] | ||
public class when_finding_types_with_multiple_implementations : given.a_type_finder | ||
{ | ||
static IEnumerable<Type> types_found; | ||
|
||
Because of = () => types_found = type_finder.FindMultiple<IMultiple>(types); | ||
|
||
It should_not_return_null = () => types_found.ShouldNotBeNull(); | ||
It should_contain_the_expected_types = () => types_found.ShouldContain(typeof (FirstMultiple), typeof (SecondMultiple)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...or_TypeFinder/when_finding_types_with_multiple_implementations_but_asking_for_a_single.cs
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,16 @@ | ||
using System; | ||
using Bifrost.Execution; | ||
using Machine.Specifications; | ||
|
||
namespace Bifrost.Specs.Execution.for_TypeFinder | ||
{ | ||
[Subject(typeof(TypeFinder))] | ||
public class when_finding_types_with_multiple_implementations_but_asking_for_a_single : given.a_type_finder | ||
{ | ||
static Exception exception; | ||
|
||
Because of = () => exception = Catch.Exception(() => type_finder.FindSingle<IMultiple>(types)); | ||
|
||
It should_throw_an_ArgumentException = () => exception.ShouldBeOfExactType<MultipleTypesFoundException>(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...Bifrost.Specs/Execution/for_TypeFinder/when_finding_types_with_only_one_implementation.cs
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,17 @@ | ||
using System; | ||
using Bifrost.Execution; | ||
using Machine.Specifications; | ||
|
||
namespace Bifrost.Specs.Execution.for_TypeFinder | ||
{ | ||
[Subject(typeof(TypeFinder))] | ||
public class when_finding_types_with_only_one_implementation : given.a_type_finder | ||
{ | ||
static Type type_found; | ||
|
||
Because of = () => type_found = type_finder.FindSingle<ISingle>(types); | ||
|
||
It should_not_return_null = () => type_found.ShouldNotBeNull(); | ||
It should_return_correct_implementation_when = () => type_found.ShouldEqual(typeof (Single)); | ||
} | ||
} |
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
Oops, something went wrong.