Sum() 공개 메소드

public Sum ( int x, int y ) : int
x int
y int
리턴 int
예제 #1
0
		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));
		}
예제 #2
0
		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);
		}
예제 #3
0
		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));
		}
예제 #4
0
		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));
		}
예제 #5
0
		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));
		}
예제 #6
0
		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));
		}