public void PrebuiltInstance(IContainerAdapter adapter)
        {
            var instance = new IndependentService();
            adapter.RegisterInstance<IService>(instance);

            var resolved = adapter.Resolve<IService>();

            Assert.Same(instance, resolved);
        }
        public void ConstructorDependencyUsingInstance(IContainerAdapter adapter)
        {
            var instance = new IndependentService();
            adapter.RegisterInstance<IService>(instance);
            adapter.RegisterType<ServiceWithSimpleConstructorDependency>();

            var dependent = adapter.Resolve<ServiceWithSimpleConstructorDependency>();

            Assert.Same(instance, dependent.Service);
        }
Example #3
0
        public void PrebuiltInstance(IFrameworkAdapter framework)
        {
            var instance = new IndependentService();

            framework.Register <IService>(instance);

            var resolved = framework.Resolve <IService>();

            Assert.Same(instance, resolved);
        }
Example #4
0
        public void PrebuiltInstance(IContainerAdapter adapter)
        {
            var instance = new IndependentService();

            adapter.RegisterInstance <IService>(instance);

            var resolved = adapter.Resolve <IService>();

            Assert.Same(instance, resolved);
        }
Example #5
0
        public void ConstructorDependencyUsingInstance(IFrameworkAdapter framework)
        {
            var instance = new IndependentService();

            framework.Register <IService>(instance);
            framework.Register <ServiceWithSimpleConstructorDependency>();

            var dependent = framework.Resolve <ServiceWithSimpleConstructorDependency>();

            Assert.Same(instance, dependent.Service);
        }
Example #6
0
        public void ConstructorDependencyUsingInstance(IContainerAdapter adapter)
        {
            var instance = new IndependentService();

            adapter.RegisterInstance <IService>(instance);
            adapter.RegisterType <ServiceWithSimpleConstructorDependency>();

            var dependent = adapter.Resolve <ServiceWithSimpleConstructorDependency>();

            Assert.Same(instance, dependent.Service);
        }
        public void FactoryWithParameterForSubdependency(IContainerAdapter adapter)
        {
            adapter.RegisterType<ServiceWithSimpleConstructorDependency>();
            adapter.RegisterType<ServiceWithDependencyOnServiceWithOtherDependency>();

            var service = new IndependentService();
            var func = adapter.Resolve<Func<IService, ServiceWithDependencyOnServiceWithOtherDependency>>();

            Assert.NotNull(func);
            var result = func(service);
            Assert.NotNull(result);
            Assert.Same(service, result.Service.Service);
        }
Example #8
0
        public void FactoryWithParameterForSubdependency(IContainerAdapter adapter)
        {
            adapter.RegisterType <ServiceWithSimpleConstructorDependency>();
            adapter.RegisterType <ServiceWithDependencyOnServiceWithOtherDependency>();

            var service = new IndependentService();
            var func    = adapter.Resolve <Func <IService, ServiceWithDependencyOnServiceWithOtherDependency> >();

            Assert.NotNull(func);
            var result = func(service);

            Assert.NotNull(result);
            Assert.Same(service, result.Service.Service);
        }
Example #9
0
 public DependentService2(IndependentService independentService)
 {
     this.IndependentService = independentService;
 }