NUnit.Framework.Assert.That(TActual, NUnit.Framework.Constraints.IResolveConstraint, System.Func)

Here are the examples of the csharp api NUnit.Framework.Assert.That(TActual, NUnit.Framework.Constraints.IResolveConstraint, System.Func) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4637 Examples 7

19 View Source File : Issue81_SupportForOptionalParametersInConstructor.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_automatically_specify_IfUnresolvedReturnDefault_for_optional_parameters()
        {
            var container = new Container();
            container.Register<Client>();

            var client = container.Resolve<Client>();

            replacedert.That(client.Dep, Is.Null);
        }

19 View Source File : Issue81_SupportForOptionalParametersInConstructor.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_keep_specified_default_parameter_value()
        {
            var container = new Container();
            container.Register<SomeService>();
            container.Register<Dep>();

            var service = container.Resolve<SomeService>();

            replacedert.That(service.Count, Is.EqualTo(3));
        }

19 View Source File : AllowDefaultTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void AllowDefault_could_be_applied_to_parameter()
        {
            var container = new Container().WithMefAttributedModel();

            container.RegisterExports(typeof(Client));

            var client = container.Resolve<Client>();
            replacedert.That(client.Service, Is.Null);
        }

19 View Source File : AllowDefaultTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void AllowDefault_could_be_applied_to_property()
        {
            var container = new Container().WithMefAttributedModel();

            container.RegisterExports(typeof(ClientProp));

            var client = container.Resolve<ClientProp>();
            replacedert.That(client.Service, Is.Null);
        }

19 View Source File : AttributedModelTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_service_with_dependencies()
        {
            var service = _container.Resolve<DependentService>();

            replacedert.That(service.TransientService, Is.Not.Null);
            replacedert.That(service.SingletonService, Is.Not.Null);
            replacedert.That(service.TransientOpenGenericService, Is.Not.Null);
            replacedert.That(service.OpenGenericServiceWithTwoParameters, Is.Not.Null);
        }

19 View Source File : AttributedModelTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_transient_service()
        {
            var service = _container.Resolve<ITransientService>();
            var anotherService = _container.Resolve<ITransientService>();

            replacedert.That(service, Is.Not.Null);
            replacedert.That(service, Is.Not.SameAs(anotherService));
        }

19 View Source File : AttributedModelTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_singleton_open_generic_service()
        {
            var service = _container.Resolve<IOpenGenericService<int>>();
            var anotherService = _container.Resolve<IOpenGenericService<int>>();

            replacedert.That(service, Is.Not.Null);
            replacedert.That(service, Is.SameAs(anotherService));
        }

19 View Source File : AttributedModelTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_service_factory()
        {
            var serviceFactory = _container.Resolve<Func<ITransientService>>();

            replacedert.That(serviceFactory(), Is.Not.Null);
        }

19 View Source File : AttributedModelTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_array_of_func_with_one_parameter()
        {
            var factories = _container.Resolve<Func<string, IServiceWithMultipleImplementations>[]>();
            replacedert.That(factories.Length, Is.EqualTo(2));

            var oneService = factories[0].Invoke("0");
            replacedert.That(oneService.Message, Is.EqualTo("0"));

            var anotherService = factories[1].Invoke("1");
            replacedert.That(anotherService.Message, Is.EqualTo("1"));
        }

19 View Source File : ExportAsDecoratorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Decorator_will_ignore_Import_attribute_on_decorated_service_constructor()
        {
            var container = new Container();
            container.RegisterExports(typeof(FastHandler), typeof(SlowHandler), typeof(DecoratorWithFastHandlerImport));

            var slow = container.Resolve<IHandler>("slow");

            replacedert.That(slow, Is.InstanceOf<DecoratorWithFastHandlerImport>());
            replacedert.That(((DecoratorWithFastHandlerImport)slow).Handler, Is.InstanceOf<SlowHandler>());
        }

19 View Source File : ImportAttributeTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Inject_service_as_Func_of_Service_with_Import_contract_type()
        {
            var container = new Container().WithMefAttributedModel();
            container.RegisterExports(typeof(FuncClient), typeof(Service));

            var client = container.Resolve<FuncClient>();

            replacedert.That(client.Some, Is.InstanceOf<Service>());
        }

19 View Source File : ImportAttributeTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Inject_service_as_Lazy_of_Service_with_Import_contract_type()
        {
            var container = new Container().WithMefAttributedModel();
            container.RegisterExports(typeof(LazyClient), typeof(Service));

            var client = container.Resolve<LazyClient>();

            replacedert.That(client.Some, Is.InstanceOf<Service>());
        }

19 View Source File : ImportAttributeTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Inject_service_as_Lazy_Meta_of_Service_with_Import_contract_type()
        {
            var container = new Container().WithMefAttributedModel();
            container.RegisterExports(typeof(LazyMetaClient), typeof(Service));

            var client = container.Resolve<LazyMetaClient>();

            replacedert.That(client.Some, Is.InstanceOf<Service>());
            replacedert.That(client.Metadata, Is.EqualTo("blah"));
        }

19 View Source File : ImportAttributeTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Inject_service_as_Func_Array_of_Service_with_Import_contract_type()
        {
            var container = new Container().WithMefAttributedModel();
            container.RegisterExports(typeof(FuncArrayClient), typeof(Service));

            var client = container.Resolve<FuncArrayClient>();

            replacedert.That(client.Some, Is.InstanceOf<Service>());
        }

19 View Source File : ImportAttributeTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Inject_service_as_Func_Array_of_Service_with_Import_contract_key_no_type_specified()
        {
            var container = new Container().WithMefAttributedModel();
            container.RegisterExports(typeof(FuncArrayKeyClient), typeof(Service), typeof(KeyService));

            var client = container.Resolve<FuncArrayKeyClient>();
            replacedert.That(client.GetServices.Length, Is.EqualTo(1));
            replacedert.That(client.GetServices[0](), Is.InstanceOf<KeyService>());
        }

19 View Source File : ImportAttributeTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Inject_property_with_default_Import_should_work()
        {
            var container = new Container().WithMefAttributedModel();
            container.RegisterExports(typeof(PropertyClient), typeof(Service));

            var client = container.Resolve<PropertyClient>();

            replacedert.That(client.Some, Is.InstanceOf<Service>());
        }

19 View Source File : ImportAttributeTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Resolve_property_for_already_resolved_instance()
        {
            var container = new Container().WithMefAttributedModel();
            container.RegisterExports(typeof(Service));

            var client = new PropertyClient();
            container.InjectPropertiesAndFields(client);

            replacedert.That(client.Some, Is.InstanceOf<Service>());
        }

19 View Source File : InheritedExportTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void It_is_possible_to_mark_interface_to_export_all_its_implementations()
        {
            var container = new Container();
            container.RegisterExports(typeof(ForExport));

            var forExport = container.Resolve<IForExport>();

            replacedert.That(forExport, Is.InstanceOf<ForExport>());
        }

19 View Source File : DryIocDataAnnotationsValidatorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Login_model_validatable_object_is_valid()
        {
            var login = new LoginModel
            {
                Username = "arabreplacedo",
                Preplacedword = "123"
            };

            _container.RegisterDelegate(c => login);

            var results = ValidateLoginObjectAdapter(login);

            replacedert.That(results, Is.Empty);
        }

19 View Source File : ChildContainerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Resolve_scoped_lazy_service_in_parent_container_with_WithoutThrowIfDependencyHreplacedhorterReuseLifespan_via_InjectPropertiesAndFields_should_not_return_null()
        {
            var container1 = new Container(rules => rules.WithoutThrowIfDependencyHreplacedhorterReuseLifespan());

            container1.Register<ServiceA>(Reuse.Scoped);

            var container2 = container1.With(
                container1.Rules.WithFactorySelector(Rules.SelectLastRegisteredFactory()), 
                null, 
                RegistrySharing.CloneAndDropCache, 
                null);

            var container2Scope = container2.OpenScope();

            var serviceB = new ServiceB();
            container2Scope.InjectPropertiesAndFields(serviceB);

            replacedert.That(serviceB.ServiceA, Is.InstanceOf<Lazy<ServiceA>>());
            replacedert.That(serviceB.ServiceA.Value, Is.Not.Null);
        }

19 View Source File : ChildContainerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Resolve_scoped_service_in_parent_container_with_WithoutThrowIfDependencyHreplacedhorterReuseLifespan_via_InjectPropertiesAndFields_should_not_return_null()
        {
            var container1 = new Container(rules => rules.WithoutThrowIfDependencyHreplacedhorterReuseLifespan());

            container1.Register<ServiceA>(Reuse.Scoped);

            var container2 = container1.With(container1.Rules.WithFactorySelector(Rules.SelectLastRegisteredFactory()), null, RegistrySharing.CloneAndDropCache, null);

            var container2Scope = container2.OpenScope();

            var serviceC = new ServiceC();
            container2Scope.InjectPropertiesAndFields(serviceC);

            replacedert.That(serviceC.ServiceA, Is.InstanceOf<ServiceA>());
            replacedert.That(serviceC.ServiceA, Is.Not.Null);
        }

19 View Source File : ChildContainerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Resolve_lazy_service_in_parent_container_should_work()
        {
            var container1 = new Container();

            container1.Register<ServiceA>(Reuse.Scoped);

            var container2 = container1.With(container1.Rules.WithFactorySelector(Rules.SelectLastRegisteredFactory()), null, RegistrySharing.CloneAndDropCache, null);

            var container2Scope = container2.OpenScope();

            var serviceB = new ServiceB();
            container2Scope.InjectPropertiesAndFields(serviceB);

            replacedert.That(serviceB.ServiceA, Is.InstanceOf<Lazy<ServiceA>>());
            replacedert.That(serviceB.ServiceA.Value, Is.Not.Null);
        }

19 View Source File : DecoratorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_resolve_closed_service_with_open_generic_decorator()
        {
            var container = new Container();
            container.Register<IOperation<int>, SomeOperation<int>>();
            container.Register(typeof(IOperation<>), typeof(MeasureExecutionTimeOperationDecorator<>), setup: Setup.Decorator);

            var operation = container.Resolve<IOperation<int>>();

            replacedert.That(operation, Is.InstanceOf<MeasureExecutionTimeOperationDecorator<int>>());
        }

19 View Source File : DecoratorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_resolve_generic_decorator_of_decorator()
        {
            var container = new Container();
            container.Register(typeof(IOperation<>), typeof(SomeOperation<>));
            container.Register(typeof(IOperation<>), typeof(MeasureExecutionTimeOperationDecorator<>), setup: Setup.Decorator);
            container.Register(typeof(IOperation<>), typeof(RetryOperationDecorator<>), setup: Setup.Decorator);

            var decorator = (RetryOperationDecorator<int>)container.Resolve<IOperation<int>>();

            replacedert.That(decorator.Decorated, Is.InstanceOf<MeasureExecutionTimeOperationDecorator<int>>());
        }

19 View Source File : DecoratorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_resolve_generic_decorator_of_closed_decorator_of_generic_service()
        {
            var container = new Container();
            container.Register(typeof(IOperation<>), typeof(SomeOperation<>));
            container.Register(typeof(IOperation<int>), typeof(MeasureExecutionTimeOperationDecorator<int>), setup: Setup.Decorator);
            container.Register(typeof(IOperation<>), typeof(RetryOperationDecorator<>), setup: Setup.Decorator);

            var decorator = (RetryOperationDecorator<int>)container.Resolve<IOperation<int>>();

            replacedert.That(decorator.Decorated, Is.InstanceOf<MeasureExecutionTimeOperationDecorator<int>>());
        }

19 View Source File : DecoratorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_resolve_decorator_array()
        {
            var container = new Container();
            container.Register<IOperation, SomeOperation>();
            container.Register<IOperation, AnotherOperation>();
            container.Register<IOperation, RetryOperationDecorator>(setup: Setup.Decorator);

            var ops = container.Resolve<IOperation[]>();

            replacedert.That(ops[0], Is.InstanceOf<RetryOperationDecorator>());
            replacedert.That(((RetryOperationDecorator)ops[0]).Decorated, Is.InstanceOf<SomeOperation>());
            replacedert.That(ops[1], Is.InstanceOf<RetryOperationDecorator>());
            replacedert.That(((RetryOperationDecorator)ops[1]).Decorated, Is.InstanceOf<AnotherOperation>());
        }

19 View Source File : DecoratorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_resolve_wrappers_of_decorator_array()
        {
            var container = new Container();
            container.Register<IOperation, SomeOperation>();
            container.Register<IOperation, AnotherOperation>();
            container.Register<IOperation, RetryOperationDecorator>(setup: Setup.Decorator);

            var ops = container.Resolve<Lazy<IOperation>[]>();

            replacedert.That(ops[0].Value, Is.InstanceOf<RetryOperationDecorator>());
            replacedert.That(((RetryOperationDecorator)ops[0].Value).Decorated, Is.InstanceOf<SomeOperation>());
            replacedert.That(ops[1].Value, Is.InstanceOf<RetryOperationDecorator>());
            replacedert.That(((RetryOperationDecorator)ops[1].Value).Decorated, Is.InstanceOf<AnotherOperation>());
        }

19 View Source File : DecoratorTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_support_multiple_decorator_in_object_graph()
        {
            var container = new Container();
            container.Register(typeof(IOperation<>), typeof(SomeOperation<>), setup: Setup.With(metadataOrFuncOfMetadata: "some"));
            container.Register(typeof(IOperation<>), typeof(RetryOperationDecorator<>), setup: Setup.Decorator);

            container.Register<IOperationUser<int>, OperationUser<int>>();
            container.Register(typeof(IOperationUser<>), typeof(LogUserOps<>), setup: Setup.Decorator);

            var user = container.Resolve<IOperationUser<int>>();
            replacedert.That(user, Is.InstanceOf<LogUserOps<int>>());
            replacedert.That(((LogUserOps<int>)user).Decorated, Is.InstanceOf<OperationUser<int>>());

            var operation = user.GetOperation.Value();
            replacedert.That(operation, Is.InstanceOf<RetryOperationDecorator<int>>());
            replacedert.That(((RetryOperationDecorator<int>)operation).Decorated, Is.InstanceOf<SomeOperation<int>>());
        }

19 View Source File : DelegateFactoryTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void While_registering_It_is_possible_to_resolve_lambda_parameters_from_container()
        {
            var container = new Container();
            container.Register<IDependency, Dependency>();
            container.RegisterDelegate(r => new ServiceWithDependency(r.Resolve<IDependency>()));

            var service = container.Resolve<ServiceWithDependency>();

            replacedert.That(service.Dependency, Is.InstanceOf<Dependency>());
        }

19 View Source File : DelegateFactoryTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_use_factory_method_instead_register_delegate_with_dependency_resolve()
        {
            var container = new Container();
            container.Register<IDependency, Dependency>();
            container.RegisterInstance<Func<IResolver, ServiceWithDependency>>(r => new ServiceWithDependency(r.Resolve<IDependency>()));
            container.Register(Made.Of(r => ServiceInfo.Of<Func<IResolver, ServiceWithDependency>>(), f => f(Arg.Of<IResolver>())));

            var service = container.Resolve<ServiceWithDependency>();

            replacedert.That(service.Dependency, Is.InstanceOf<Dependency>());
        }

19 View Source File : DelegateFactoryTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_use_factory_method_instead_register_delegate_with_dependency_resolve_Better_approach()
        {
            var container = new Container();
            container.Register<IDependency, Dependency>();
            container.Register(Made.Of(() => new ServiceWithDependency(Arg.Of<IDependency>())));

            var service = container.Resolve<ServiceWithDependency>();

            replacedert.That(service.Dependency, Is.InstanceOf<Dependency>());
        }

19 View Source File : DelegateFactoryTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Possible_to_Register_delegate_with_runtime_type_of_service()
        {
            var container = new Container();

            container.RegisterDelegate(typeof (IService), _ => new Service());

            var service = container.Resolve<IService>();
            replacedert.That(service, Is.InstanceOf<Service>());
        }

19 View Source File : DynamicFactoryTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_service_with_not_registered_lazy_parameter_using_dynamic_factory()
        {
            var container = new Container();
            container.Register<ServiceWithNotRegisteredLazyParameter>();
            container.Register(typeof(DynamicFactory<>));
            container.RegisterInstance(container);

            var service = container.Resolve<ServiceWithNotRegisteredLazyParameter>();

            replacedert.That(service.Parameter.CanCreate, Is.False);

            container.Register<NotRegisteredService>();

            replacedert.That(service.Parameter.CanCreate, Is.True);
            replacedert.That(service.Parameter.Create(), Is.Not.Null);
        }

19 View Source File : DynamicFactoryTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_resolve_Func_of_Lazy()
        {
            var container = new Container();
            container.Register<IServiceWithDependency, ServiceWithDependency>();
            container.Register(typeof(Service));
            container.Register(typeof(LazyDynamic<>), setup: Setup.Wrapper);

            var func = container.Resolve<Func<LazyDynamic<IServiceWithDependency>>>();
            var service = func().Value.Value;

            replacedert.That(service.Dependency, Is.InstanceOf<Service>());
        }

19 View Source File : EnumerableAndArrayTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_array_of_singletons()
        {
            var container = new Container();
            container.Register(typeof(IService), typeof(Service), Reuse.Singleton);

            var services = container.Resolve<IService[]>();

            replacedert.That(services.Length, Is.EqualTo(1));
        }

19 View Source File : EnumerableAndArrayTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Resolving_enumerable_of_service_should_return_enumerable_type()
        {
            var container = new Container();
            container.Register(typeof(IService), typeof(Service));

            var services = container.Resolve<IEnumerable<IService>>();

            replacedert.That(services, Is.InstanceOf<IEnumerable<IService>>());
        }

19 View Source File : EnumerableAndArrayTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        [TestCase(true)]
        [TestCase(false)]
        public void I_can_resolve_array_of_open_generics(bool lazyEnumerable)
        {
            IContainer container = new Container();
            if (lazyEnumerable)
                container = container.With(r => r.WithResolveIEnumerableAsLazyEnumerable());

            container.Register(typeof(IService<>), typeof(Service<>), Reuse.Singleton);

            var services = container.Resolve<IEnumerable<IService<int>>>();

            replacedert.That(services.Single(), Is.InstanceOf<Service<int>>());
        }

19 View Source File : EnumerableAndArrayTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_array_of_lazy_singletons()
        {
            var container = new Container();
            ServiceWithInstanceCount.InstanceCount = 0;

            container.Register(typeof(ServiceWithInstanceCount), Reuse.Singleton);

            var services = container.Resolve<IEnumerable<Lazy<ServiceWithInstanceCount>>>();
            replacedert.That(ServiceWithInstanceCount.InstanceCount, Is.EqualTo(0));

            var service = services.First().Value;
            replacedert.That(service, Is.Not.Null);

            replacedert.That(ServiceWithInstanceCount.InstanceCount, Is.EqualTo(1));
        }

19 View Source File : FuncTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Given_implementation_with_many_constructor_primitive_parameters_Possible_to_resolve_service_as_Func_of_many_parameters()
        {
            var container = new Container();
            container.Register(typeof(ServiceWithTwoPrimitiveParameters));

            var func = container.Resolve<Func<bool, string, ServiceWithTwoPrimitiveParameters>>();
            var service = func(true, "hey");

            replacedert.That(service.Flag, Is.True);
            replacedert.That(service.Message, Is.EqualTo("hey"));
        }

19 View Source File : FuncTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Given_registered_singleton_Resolved_Func_of_one_parameter_should_create_same_instances_Where_created_first_will_determine_parameter_value()
        {
            var container = new Container();
            container.Register<ServiceWithOnePrimitiveParameter>(Reuse.Singleton);

            var func = container.Resolve<Func<string, ServiceWithOnePrimitiveParameter>>();
            var one = func.Invoke("one");
            var another = func.Invoke("another");

            replacedert.That(one, Is.SameAs(another));
            replacedert.That(another.Message, Is.EqualTo("one"));
        }

19 View Source File : FuncTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Given_constructor_with_two_parameters_Resolving_Func_twice_with_one_BUT_different_parameter_should_work()
        {
            var container = new Container();
            container.Register(typeof(ServiceWithTwoParameters));
            container.Register(typeof(Service));
            container.Register(typeof(AnotherService), typeof(AnotherService));

            var firstFunc = container.Resolve<Func<Service, ServiceWithTwoParameters>>();
            var one = new Service();
            var first = firstFunc(one);

            replacedert.That(first.One, Is.SameAs(one));

            var secondFunc = container.Resolve<Func<AnotherService, ServiceWithTwoParameters>>();
            var another = new AnotherService();
            var second = secondFunc(another);

            replacedert.That(second.Another, Is.SameAs(another));
        }

19 View Source File : FuncTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_resolve_sub_dependency_with_func_argument()
        {
            var container = new Container();
            container.Register<ClreplacedWithDepAndSubDep>();
            container.Register<DepWithSubDep>();

            var func = container.Resolve<Func<string, ClreplacedWithDepAndSubDep>>();
            var service = func("Hey");

            replacedert.That(service.Dep.Message, Is.EqualTo("Hey"));
        }

19 View Source File : InitializerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_register_initializer_as_decorator_delegate()
        {
            var container = new Container();
            container.Register<InitializableService>();
            container.RegisterDelegateDecorator<InitializableService>(r => (x =>
            {
                x.Initialize("blah");
                return x;
            }));

            var service = container.Resolve<InitializableService>();

            replacedert.That(service.Data, Is.EqualTo("blah"));
        }

19 View Source File : InitializerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_register_initializer_as_decorator_delegate_of_generic_impl()
        {
            var container = new Container();
            container.Register<IInitializable<InitializableService>, InitializableService>();
            container.RegisterDelegateDecorator<IInitializable<InitializableService>>(
                r => x => x.Initialize("blah"));

            var service = (InitializableService)container.Resolve<IInitializable<InitializableService>>();

            replacedert.That(service.Data, Is.EqualTo("blah"));
        }

19 View Source File : InitializerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_register_initializer_as_decorator_delegate_with_dedicated_method()
        {
            var container = new Container();
            container.Register<InitializableService>();
            container.RegisterInitializer<IInitializable>((x, _) => x.Initialize("yeah"));

            var service = container.Resolve<InitializableService>();

            replacedert.That(service.Data, Is.EqualTo("yeah"));
        }

19 View Source File : InitializerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_register_and_inject_initializer_as_decorator_delegate_with_dedicated_method()
        {
            var container = new Container();
            container.Register<ClientOfInitializableService>();
            container.Register<InitializableService>();
            container.RegisterInitializer<IInitializable>((x, _) => x.Initialize("yeah"));

            var client = container.Resolve<ClientOfInitializableService>();

            replacedert.That(client.Service.Data, Is.EqualTo("yeah"));
        }

19 View Source File : InitializerTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Can_register_and_call_one_initializer_multiple_times_with_different_parameters()
        {
            var container = new Container();
            container.Register<ClientOfInitializableService>();
            container.Register<InitializableService>();
            container.RegisterInitializer<IInitializable>((x, _) => x.Initialize("green"));
            container.RegisterInitializer<IInitializable>((x, _) => x.Initialize("-blah"));

            var client = container.Resolve<ClientOfInitializableService>();

            replacedert.That(client.Service.Data, Is.EqualTo("green-blah"));
        }

19 View Source File : InjectionRulesTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Should_simply_specify_that_all_replacedignable_properties_and_fiels_should_be_resolved()
        {
            var container = new Container();
            container.Register<IService, Service>();
            container.RegisterMany<ClientWithPropsAndFields>(made: Made.Of(propertiesAndFields: PropertiesAndFields.Auto));

            var client = container.Resolve<ClientWithPropsAndFields>();

            replacedert.That(client.F, Is.InstanceOf<Service>());
            replacedert.That(client.P, Is.InstanceOf<Service>());
            replacedert.That(client.PNonResolvable, Is.Null);
        }

19 View Source File : InjectionRulesTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void I_can_resolve_property_with_internal_setter()
        {
            var container = new Container();
            container.Register<IService, Service>(serviceKey: "key");
            container.RegisterMany(Made.Of(() => new ClientWithPropsAndFields { PWithInternalSetter = Arg.Of<IService>(IfUnresolved.Throw, "key") }));

            var client = container.Resolve<ClientWithPropsAndFields>();

            replacedert.That(client.PWithInternalSetter, Is.InstanceOf<Service>());
        }

19 View Source File : KeyValuePairResolutionTests.cs
License : MIT License
Project Creator : dadhi

[Test]
        public void Resolve_indexed_registration_as_pair_When_resolving_with_that_index_should_Succeed()
        {
            var container = new Container();
            container.Register<Service>(serviceKey: 0);

            var pair = container.Resolve<KeyValuePair<object, Service>>(serviceKey: 0);

            replacedert.That(pair.Key, Is.EqualTo(0));
            replacedert.That(pair.Value, Is.InstanceOf<Service>());
        }

See More Examples