Skip to content

Instantly share code, notes, and snippets.

@burkeholland
Forked from derekgreer/MonarchySpecs.cs
Created July 23, 2011 01:19
Show Gist options
  • Save burkeholland/1100810 to your computer and use it in GitHub Desktop.
Save burkeholland/1100810 to your computer and use it in GitHub Desktop.
Monarchy Refactored Specs
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