コード例 #1
0
		public void GetSingletonNonStatic()
		{
			TestClass1 tc1 = new TestClass1();
			MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();
			mcfo.TargetObject = tc1;
			mcfo.TargetMethod = "Method1";
			mcfo.AfterPropertiesSet();
			int i = (int) mcfo.GetObject();
			Assert.IsTrue(i == 1);
			i = (int) mcfo.GetObject();
			Assert.IsTrue(i == 1);
			Assert.IsTrue(mcfo.IsSingleton);
		}
コード例 #2
0
        public void GetSingletonNonStatic()
        {
            TestClass1 tc1 = new TestClass1();
            MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();

            mcfo.TargetObject = tc1;
            mcfo.TargetMethod = "Method1";
            mcfo.AfterPropertiesSet();
            int i = (int)mcfo.GetObject();

            Assert.IsTrue(i == 1);
            i = (int)mcfo.GetObject();
            Assert.IsTrue(i == 1);
            Assert.IsTrue(mcfo.IsSingleton);
        }
コード例 #3
0
        public void GetSingletonStatic()
        {
            TestClass1._staticField1 = 0;
            MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();

            mcfo.TargetType   = typeof(TestClass1);
            mcfo.TargetMethod = "StaticMethod1";
            mcfo.AfterPropertiesSet();
            int i = (int)mcfo.GetObject();

            Assert.IsTrue(i == 1);
            i = (int)mcfo.GetObject();
            Assert.IsTrue(i == 1);
            Assert.IsTrue(mcfo.IsSingleton);
        }
コード例 #4
0
        public void InvokingAMethodThatHasAVoidReturnTypeReturnsNullPlaceHolder()
        {
            MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();

            mcfo.TargetType   = typeof(TestClass1);
            mcfo.TargetMethod = "VoidRetvalMethod";
            mcfo.AfterPropertiesSet();
            Assert.AreEqual(MethodInvoker.Void, mcfo.GetObject());
        }
コード例 #5
0
        public void InvokeGenericMethod()
        {
            TestClass1 tc1 = new TestClass1();
            MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();
            mcfo.TargetType = typeof(Activator);
            mcfo.TargetMethod = "CreateInstance<Spring.Objects.TestObject>";
            mcfo.AfterPropertiesSet();

            object obj = mcfo.GetObject();
            Assert.IsNotNull(obj);
            Assert.IsTrue(obj is TestObject);
        }
コード例 #6
0
        public void InvokeGenericMethod()
        {
            TestClass1 tc1 = new TestClass1();
            MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();

            mcfo.TargetType   = typeof(Activator);
            mcfo.TargetMethod = "CreateInstance<Spring.Objects.TestObject>";
            mcfo.AfterPropertiesSet();

            object obj = mcfo.GetObject();

            Assert.IsNotNull(obj);
            Assert.IsTrue(obj is TestObject);
        }
コード例 #7
0
		public void GetSingletonStatic()
		{
			TestClass1._staticField1 = 0;
			MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();
			mcfo.TargetType = typeof (TestClass1);
			mcfo.TargetMethod = "StaticMethod1";
			mcfo.AfterPropertiesSet();
			int i = (int) mcfo.GetObject();
			Assert.IsTrue(i == 1);
			i = (int) mcfo.GetObject();
			Assert.IsTrue(i == 1);
			Assert.IsTrue(mcfo.IsSingleton);
		}
コード例 #8
0
		public void InvokingAMethodThatHasAVoidReturnTypeReturnsNullPlaceHolder()
		{
			MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject();
			mcfo.TargetType = typeof (TestClass1);
			mcfo.TargetMethod = "VoidRetvalMethod";
			mcfo.AfterPropertiesSet();
			Assert.AreEqual(MethodInvoker.Void, mcfo.GetObject());
		}