-
-
Save burkeholland/1100810 to your computer and use it in GitHub Desktop.
Monarchy Refactored Specs
This file contains hidden or 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 Machine.Specifications; | |
namespace Monarchy.Specs | |
{ | |
[Subject(typeof (ObjectFactory))] | |
public class when_retrieving_a_type_with_registered_dependency_factory | |
{ | |
static TestService _instance; | |
static ObjectFactory _factory; | |
Establish context = () => | |
{ | |
_factory = new ObjectFactory(); | |
_factory.Register<IDependencyService>(() => new DependencyServiceImpl()); | |
}; | |
Because of = () => _instance = _factory.Get<TestService>(); | |
It should_return_the_instance = () => _instance.ShouldNotBeNull(); | |
} | |
[Subject(typeof(ObjectFactory))] | |
public class when_retrieving_a_type_with_a_registered_dependency_type | |
{ | |
static TestService _instance; | |
static ObjectFactory _factory; | |
Establish context = () => | |
{ | |
_factory = new ObjectFactory(); | |
_factory.Register<IDependencyService, DependencyServiceImpl>(); | |
}; | |
Because of = () => _instance = _factory.Get<TestService>(); | |
It should_return_the_instance = () => _instance.ShouldNotBeNull(); | |
} | |
public class TestService | |
{ | |
readonly IDependencyService _dependencyService; | |
public TestService(IDependencyService dependencyService) | |
{ | |
_dependencyService = dependencyService; | |
} | |
} | |
public interface IDependencyService | |
{ | |
} | |
public class DependencyServiceImpl : IDependencyService | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment