public void GetObjectType() { TestClass1 tc1 = new TestClass1(); MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = tc1; mcfo.TargetMethod = "Method1"; mcfo.AfterPropertiesSet(); Assert.IsTrue(typeof(int).Equals(mcfo.ObjectType)); mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "VoidRetvalMethod"; mcfo.AfterPropertiesSet(); Type objType = mcfo.ObjectType; Assert.IsTrue(objType.Equals(MethodInvokingFactoryObject.Void.GetType())); // verify that we can call a method with args that are subtypes of the // target method arg types TestClass1._staticField1 = 0; mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] { new ArrayList(), new ArrayList(), "hello" }; mcfo.AfterPropertiesSet(); objType = mcfo.ObjectType; }
public void AfterPropertiesSetMissingMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = this; Assert.Throws <ArgumentException>(() => mcfo.AfterPropertiesSet()); }
public void AfterPropertiesSetMissingMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = this; mcfo.AfterPropertiesSet(); }
public void AfterPropertiesSetStaticMethodMissingArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Method1"; Assert.Throws <ArgumentException>(() => mcfo.AfterPropertiesSet()); }
public void AfterPropertiesSetBogusStaticMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "some.bogus.Method.name"; Assert.Throws <MissingMethodException>(() => mcfo.AfterPropertiesSet()); }
public void AfterPropertiesSetBogusMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = this; mcfo.TargetMethod = "whatever"; mcfo.AfterPropertiesSet(); }
public void AfterPropertiesSetBogusStaticMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "some.bogus.Method.name"; mcfo.AfterPropertiesSet(); }
public void AfterPropertiesSetStaticMethodMissingArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Method1"; mcfo.AfterPropertiesSet(); }
public void AfterPropertiesSetBogusMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = this; mcfo.TargetMethod = "whatever"; Assert.Throws <MissingMethodException>(() => mcfo.AfterPropertiesSet()); }
public void InvokingAMethodThatHasAVoidReturnTypeReturnsNullPlaceHolder() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "VoidRetvalMethod"; mcfo.AfterPropertiesSet(); Assert.AreEqual(MethodInvoker.Void, mcfo.GetObject()); }
public void GetSupertypesTooManyArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Supertypes2"; mcfo.Arguments = new Object[] { new ArrayList(), new ArrayList(), "hello", "bogus" }; mcfo.AfterPropertiesSet(); }
public void GetSupertypesTooManyArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Supertypes2"; mcfo.Arguments = new Object[] { new ArrayList(), new ArrayList(), "hello", "bogus" }; Assert.Throws <ArgumentException>(() => mcfo.AfterPropertiesSet(), "Unable to determine which exact method to call; found '2' matches."); }
public void GetMisMatchedArgumentTypes() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] { "1", "2", "3" }; Assert.Throws <TypeMismatchException>(() => mcfo.AfterPropertiesSet()); }
public void GetMisMatchedArgumentTypes() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] { "1", "2", "3" }; mcfo.AfterPropertiesSet(); mcfo.Invoke(); }
public void GetSupertypesMatchNumArgs() { TestClass1._staticField1 = 0; MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof(TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] { new ArrayList(), new ArrayList(), "hello" }; // should pass mcfo.AfterPropertiesSet(); }
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 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 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 BailsIfTheTargetMethodPropertyAintSet() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.AfterPropertiesSet(); }
public void InvokingAMethodThatHasAVoidReturnTypeReturnsNullPlaceHolder() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "VoidRetvalMethod"; mcfo.AfterPropertiesSet(); Assert.AreEqual(MethodInvoker.Void, mcfo.GetObject()); }
public void GetSupertypesMatchNumArgs() { TestClass1._staticField1 = 0; MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] {new ArrayList(), new ArrayList(), "hello"}; // should pass mcfo.AfterPropertiesSet(); }
public void GetMisMatchedArgumentTypes() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] {"1", "2", "3"}; mcfo.AfterPropertiesSet(); mcfo.Invoke(); }
public void BailsIfTheTargetMethodPropertyAintSet() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); Assert.Throws<ArgumentException>(() => mcfo.AfterPropertiesSet(), "The 'TargetMethod' property is required."); }
public void AfterPropertiesSetBogusStaticMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "some.bogus.Method.name"; Assert.Throws<MissingMethodException>(() => mcfo.AfterPropertiesSet()); }
public void AfterPropertiesSetBogusMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = this; mcfo.TargetMethod = "whatever"; Assert.Throws<MissingMethodException>(() => mcfo.AfterPropertiesSet()); }
public void AfterPropertiesSetStaticMethodMissingArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Method1"; Assert.Throws<ArgumentException>(() => mcfo.AfterPropertiesSet()); }
public void BailsIfTheTargetMethodPropertyAintSet() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); Assert.Throws <ArgumentException>(() => mcfo.AfterPropertiesSet(), "The 'TargetMethod' property is required."); }
public void AfterPropertiesSetMissingMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = this; Assert.Throws<ArgumentException>(() => mcfo.AfterPropertiesSet()); }
public void AfterPropertiesSetStaticMethodMissingArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Method1"; mcfo.AfterPropertiesSet(); }
public void GetObjectType() { TestClass1 tc1 = new TestClass1(); MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetObject = tc1; mcfo.TargetMethod = "Method1"; mcfo.AfterPropertiesSet(); Assert.IsTrue(typeof (int).Equals(mcfo.ObjectType)); mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "VoidRetvalMethod"; mcfo.AfterPropertiesSet(); Type objType = mcfo.ObjectType; Assert.IsTrue(objType.Equals(MethodInvoker.Void.GetType())); // verify that we can call a method with args that are subtypes of the // target method arg types TestClass1._staticField1 = 0; mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] {new ArrayList(), new ArrayList(), "hello"}; mcfo.AfterPropertiesSet(); objType = mcfo.ObjectType; }
public void AfterPropertiesSetBogusStaticMethod() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "some.bogus.Method.name"; mcfo.AfterPropertiesSet(); }
public void GetMisMatchedArgumentTypes() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Supertypes"; mcfo.Arguments = new Object[] {"1", "2", "3"}; Assert.Throws<TypeMismatchException>(() => mcfo.AfterPropertiesSet()); }
public void GetSupertypesTooManyArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Supertypes2"; mcfo.Arguments = new Object[] {new ArrayList(), new ArrayList(), "hello", "bogus"}; Assert.Throws<ArgumentException>(() => mcfo.AfterPropertiesSet(), "Unable to determine which exact method to call; found '2' matches."); }
public void GetSupertypesTooManyArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Supertypes2"; mcfo.Arguments = new Object[] {new ArrayList(), new ArrayList(), "hello", "bogus"}; mcfo.AfterPropertiesSet(); }
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); }