public void requesting_a_type_with_a_public_constructor_returns_a_new_instance_of_that_type()
 {
     Resolver.AddDependency <ISimple, Simple>();
     Resolver.Resolve <ISimple>().ShouldBeAssignableTo <Simple>();
 }
 public void registering_a_concrete_type_results_in_the_type_being_registered()
 {
     Resolver.AddDependency(typeof(Simple), DependencyLifetime.Transient);
     Resolver.HasDependency(typeof(Simple)).ShouldBeTrue();
 }
 public void registering_a_service_type_with_an_unknown_dependency_lifetime_value_results_in__an_error()
 {
     Executing(() => Resolver.AddDependency <ISimple, Simple>((DependencyLifetime)999))
     .ShouldThrow <InvalidOperationException>();
 }
        public void a_property_that_would_cause_a_cyclic_dependency_is_ignored()
        {
            Resolver.AddDependency <RecursiveProperty>();

            Resolver.Resolve <RecursiveProperty>().Property.ShouldBeNull();
        }
        public void registered_concrete_type_is_recognized_as_dependency_implementation()
        {
            Resolver.AddDependency <ISimple, Simple>();

            Resolver.HasDependencyImplementation(typeof(ISimple), typeof(Simple)).ShouldBeTrue();
        }
 public void an_interface_cannot_be_registered_as_a_concrete_implementation()
 {
     Executing(() => Resolver.AddDependency <ISimple, IAnotherSimple>()).ShouldThrow <InvalidOperationException>();
 }
        public void cyclic_dependency_generates_an_error()
        {
            Resolver.AddDependency <RecursiveConstructor>();

            Executing(() => Resolver.Resolve <RecursiveConstructor>()).ShouldThrow <DependencyResolutionException>();
        }
        public void a_type_registered_as_per_request_cannot_be_resolved_if_IContextStore_is_not_registered()
        {
            Resolver.AddDependency <ISimple, Simple>(DependencyLifetime.PerRequest);

            Executing(() => Resolver.Resolve <ISimple>()).ShouldThrow <DependencyResolutionException>();
        }
 public void an_abstract_type_cannot_be_registered()
 {
     Executing(() => Resolver.AddDependency <ISimple, SimpleAbstract>()).ShouldThrow <InvalidOperationException>();
 }
Exemplo n.º 10
0
 public void only_the_specified_abstract_type_is_registered()
 {
     Resolver.AddDependency <IFoo, FooBar>();
     Resolver.HasDependency <IFoo>().ShouldBe(true);
     Resolver.HasDependency <IBar>().ShouldBe(false);
 }
        public void a_type_cannot_be_created_when_its_dependencies_are_not_registered()
        {
            Resolver.AddDependency <IAnother, Another>();

            Executing(() => Resolver.Resolve <IAnother>()).ShouldThrow <DependencyResolutionException>();
        }
Exemplo n.º 12
0
 public void concrete_dependencies_can_only_be_found_by_their_concrete_type()
 {
     Resolver.AddDependency <AFoo>();
     Resolver.HasDependency <AFoo>().ShouldBe(true);
     Resolver.HasDependency <IFoo>().ShouldBe(false);
 }
Exemplo n.º 13
0
 public void abstract_dependencies_can_be_found_by_either_type()
 {
     Resolver.AddDependency <IFoo, AFoo>();
     Resolver.HasDependency <IFoo>().ShouldBe(true);
     Resolver.HasDependency <AFoo>().ShouldBe(true);
 }
 public void can_resolve_type()
 {
     Resolver.AddDependency <DependsOnFuncOfSimple>();
     Should.NotThrow(() => Resolver.Resolve <DependsOnFuncOfSimple>());
 }
Exemplo n.º 15
0
 public void resolving_func_of_enums()
 {
     Resolver.AddDependency <Simple>();
     Should.NotThrow(() => Resolver.Resolve <Func <IEnumerable <Simple> > >()().ShouldHaveSingleItem().ShouldNotBeNull());
 }
Exemplo n.º 16
0
 public void GivenUriDecorator <T>() where T : class, IUriDecorator
 {
     Resolver.AddDependency <IUriDecorator, T>();
 }