Sum() public method

public Sum ( int x, int y ) : int
x int
y int
return int
		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 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 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 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 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 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_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));
		}