public void GetExistingServiceFromKernel() { WindsorContainer windsor = new WindsorContainer(); ((IWindsorContainer)windsor).Register(MicroKernel.Registration.Component.For(typeof(ICalcService)).ImplementedBy(typeof(CalculatorService)).Named("calculator")); IContainerAdapter adapter = new ContainerAdapter(windsor); ICalcService service = (ICalcService) adapter.GetService(typeof(ICalcService)); Assert.IsNotNull(service); }
public void GetExistingServiceFromKernel() { WindsorContainer windsor = new WindsorContainer(); windsor.AddComponent("calculator", typeof(ICalcService), typeof(CalculatorService)); IContainerAdapter adapter = new ContainerAdapter(windsor); ICalcService service = (ICalcService) adapter.GetService(typeof(ICalcService)); Assert.IsNotNull(service); }
public void AddPromotedServiceCreatorCallback() { var child = new ContainerAdapter(); container.Add(child); ServiceCreatorCallback callback = CreateCalculatorService; child.AddService(typeof(ICalcService), callback, true); var service = (ICalcService)child.GetService(typeof(ICalcService)); Assert.IsNotNull(service); var promotedService = (ICalcService)container.GetService(typeof(ICalcService)); Assert.IsNotNull(service); Assert.AreSame(service, promotedService); container.Remove(child); Assert.IsNull(child.GetService(typeof(ICalcService))); Assert.AreSame(container.GetService(typeof(ICalcService)), service); }
public void RemovePromotedServiceInstance() { var child = new ContainerAdapter(); container.Add(child); ICalcService service = new CalculatorService(); child.AddService(typeof(ICalcService), service, true); Assert.IsNotNull(child.GetService(typeof(ICalcService))); child.RemoveService(typeof(ICalcService), true); Assert.IsNull(child.GetService(typeof(ICalcService))); Assert.IsNull(container.GetService(typeof(ICalcService))); }
public void GetExistingServiceFromKernel() { var adapter = new ContainerAdapter(new WindsorContainer() .Register(Castle.MicroKernel.Registration.Component.For<ICalcService>() .ImplementedBy<CalculatorService>())); var service = (ICalcService)adapter.GetService(typeof(ICalcService)); Assert.IsNotNull(service); }