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); }
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); }
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); }
public void InvokingAMethodThatHasAVoidReturnTypeReturnsNullPlaceHolder() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "VoidRetvalMethod"; mcfo.AfterPropertiesSet(); Assert.AreEqual(MethodInvoker.Void, mcfo.GetObject()); }
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); }
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); }
public void InvokingAMethodThatHasAVoidReturnTypeReturnsNullPlaceHolder() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "VoidRetvalMethod"; mcfo.AfterPropertiesSet(); Assert.AreEqual(MethodInvoker.Void, mcfo.GetObject()); }