Summary description for CalculatorService.
Inheritance: ICalcService
		public void ChainContainers()
		{
			ICalcService service = new CalculatorService();
			container.AddService(typeof(ICalcService), service);

			IContainerAdapter adapter = new ContainerAdapter(container);

			Assert.AreSame(service, container.GetService(typeof(ICalcService)));
		}
		public void ClassProxy()
		{
			container.AddComponent("interceptor", typeof(ResultModifierInterceptor));
			container.AddComponent("key", typeof(CalculatorService));

			service = container.Resolve<CalculatorService>("key");

			Assert.IsNotNull(service);
			Assert.AreEqual(7, service.Sum(2, 2));
		}
		public void AddServiceInstance()
		{
			ICalcService service = new CalculatorService();

			container.AddService(typeof(ICalcService), service);

			Assert.AreSame(container.GetService(typeof(ICalcService)), service);
			Assert.AreSame(container.Container.Resolve<ICalcService>(), service);
		}
		public void Xml_multiple_interceptors_resolves_correctly()
		{
			container.Install(Windsor.Installer.Configuration.FromXmlFile(ConfigHelper.ResolveConfigPath("InterceptorsMultiple.config")));
			service = container.Resolve<CalculatorService>("component");

			Assert.IsNotNull(service);
			Assert.AreEqual(10, service.Sum(2, 2));
		}
		public void Multithreaded()
		{
			container.AddComponent("interceptor", typeof(ResultModifierInterceptor));
			container.AddComponent("key", typeof(CalculatorService));

			service = (CalculatorService) container.Resolve("key");

			const int threadCount = 10;

			Thread[] threads = new Thread[threadCount];

			for(int i = 0; i < threadCount; i++)
			{
				threads[i] = new Thread(new ThreadStart(ExecuteMethodUntilSignal));
				threads[i].Start();
			}

			startEvent.Set();

			Thread.CurrentThread.Join(1 * 2000);

			stopEvent.Set();
		}
		public void Xml_mixin()
		{
			container.Install(Castle.Windsor.Installer.Configuration.FromXmlFile(ConfigHelper.ResolveConfigPath("Mixins.config")));
			service = container.Resolve<CalculatorService>("ValidComponent");

			Assert.IsInstanceOf<ISimpleMixIn>(service);

			((ISimpleMixIn)service).DoSomething();
		}
		public void Multithreaded()
		{
			container.Register(Component.For(typeof(ResultModifierInterceptor)).Named("interceptor"));
			container.Register(Component.For(typeof(CalculatorService)).Named("key"));

			service = container.Resolve<CalculatorService>("key");

			const int threadCount = 10;

			var threads = new Thread[threadCount];

			for (var i = 0; i < threadCount; i++)
			{
				threads[i] = new Thread(ExecuteMethodUntilSignal);
				threads[i].Start();
			}

			startEvent.Set();

			Thread.CurrentThread.Join(2000);

			stopEvent.Set();
		}
		public void Xml_mixin()
		{
			container.Install(XmlResource("mixins.xml"));
			service = container.Resolve<CalculatorService>("ValidComponent");

			Assert.IsInstanceOf<ISimpleMixIn>(service);

			((ISimpleMixIn)service).DoSomething();
		}
		public void Xml_additionalInterfaces()
		{
			container.Install(XmlResource("additionalInterfaces.xml"));
			service = container.Resolve<CalculatorService>("ValidComponent");

			Assert.IsInstanceOf<ISimpleMixIn>(service);

			Assert.Throws(typeof(System.NotImplementedException), () =>
			                                                      ((ISimpleMixIn)service).DoSomething());
		}
		public void Xml_validComponent_resolves_correctly()
		{
			container.Install(XmlResource("interceptors.xml"));
			service = container.Resolve<CalculatorService>("ValidComponent");

			Assert.IsNotNull(service);
			Assert.AreEqual(5, service.Sum(2, 2));
		}
		public void Xml_multiple_interceptors_resolves_correctly()
		{
			container.Install(XmlResource("interceptorsMultiple.xml"));
			service = container.Resolve<CalculatorService>("component");

			Assert.IsNotNull(service);
			Assert.AreEqual(10, service.Sum(2, 2));
		}
		public void ClassProxy()
		{
			container.Register(Component.For(typeof(ResultModifierInterceptor)).Named("interceptor"));
			container.Register(Component.For(typeof(CalculatorService)).Named("key"));

			service = container.Resolve<CalculatorService>("key");

			Assert.IsNotNull(service);
			Assert.AreEqual(5, service.Sum(2, 2));
		}
		public void Xml_hook_and_selector()
		{
			container.Install(
				Castle.Windsor.Installer.Configuration.FromXmlFile(ConfigHelper.ResolveConfigPath("InterceptorsWithHookAndSelector.config")));
			var model = this.container.Kernel.GetHandler("ValidComponent").ComponentModel;
			var options = ProxyUtil.ObtainProxyOptions(model, false);

			Assert.IsNotNull(options);
			Assert.IsNotNull(options.Selector);
			Assert.IsNotNull(options.Hook);
			Assert.AreEqual(0, SelectAllSelector.Instances);
			Assert.AreEqual(0, ProxyAllHook.Instances);

			service = this.container.Resolve<CalculatorService>("ValidComponent");

			Assert.AreEqual(1, SelectAllSelector.Instances);
			Assert.AreEqual(0, SelectAllSelector.Calls);
			Assert.AreEqual(1, ProxyAllHook.Instances);

			service.Sum(2, 2);

			Assert.AreEqual(1, SelectAllSelector.Calls);
		}
		public void Xml_additionalInterfaces()
		{
			container.Install(Castle.Windsor.Installer.Configuration.FromXmlFile(ConfigHelper.ResolveConfigPath("AdditionalInterfaces.config")));
			service = container.Resolve<CalculatorService>("ValidComponent");

			Assert.IsInstanceOf<ISimpleMixIn>(service);

			Assert.Throws(typeof(System.NotImplementedException), () =>

				((ISimpleMixIn)service).DoSomething());
		}
		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 Xml_hook_and_selector()
		{
			ProxyAllHook.Instances = 0;
			SelectAllSelector.Calls = 0;
			SelectAllSelector.Instances = 0;
			container.Install(XmlResource("interceptorsWithHookAndSelector.xml"));
			var model = container.Kernel.GetHandler("ValidComponent").ComponentModel;
			var options = ProxyUtil.ObtainProxyOptions(model, false);

			Assert.IsNotNull(options);
			Assert.IsNotNull(options.Selector);
			Assert.IsNotNull(options.Hook);
			Assert.AreEqual(0, SelectAllSelector.Instances);
			Assert.AreEqual(0, ProxyAllHook.Instances);

			service = container.Resolve<CalculatorService>("ValidComponent");

			Assert.AreEqual(1, SelectAllSelector.Instances);
			Assert.AreEqual(0, SelectAllSelector.Calls);
			Assert.AreEqual(1, ProxyAllHook.Instances);

			service.Sum(2, 2);

			Assert.AreEqual(1, SelectAllSelector.Calls);
		}
		public void RemoveServiceInstance()
		{
			ICalcService service = new CalculatorService();

			container.AddService(typeof(ICalcService), service);
			container.RemoveService(typeof(ICalcService));
			Assert.IsNull(container.GetService(typeof(ICalcService)));
			Assert.IsFalse(container.Container.Kernel.HasComponent(typeof(ICalcService)));
		}
		public void Xml_validComponent_resolves_correctly()
		{
			container.Install(Castle.Windsor.Installer.Configuration.FromXmlFile(ConfigHelper.ResolveConfigPath("Interceptors.config")));
			service = container.Resolve<CalculatorService>("ValidComponent");

			Assert.IsNotNull(service);
			Assert.AreEqual(5, service.Sum(2, 2));
		}