public void SettingNamedArgumentsToNullJustClearsOutAnyNamedArguments() { MethodInvoker vkr = new MethodInvoker(); vkr.AddNamedArgument("age", 10); vkr.NamedArguments = null; Assert.IsNotNull(vkr.NamedArguments); Assert.AreEqual(0, vkr.NamedArguments.Count); }
public void NamedArgumentsOverwriteEachOther() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("years", 10); // this second setting must overwrite the first... vkr.AddNamedArgument("years", 200); vkr.Prepare(); object actual = vkr.Invoke(); Assert.IsFalse(98.Equals(actual), "The first named argument setter is sticking; must allow itslf to be overwritten."); Assert.AreEqual(288, actual, "The second named argument was not applied (it must be)."); }
public void SettingNamedArgumentsToNullJustClearsOutAnyNamedArguments() { MethodInvoker vkr = new MethodInvoker(); vkr.AddNamedArgument("age", 10); vkr.NamedArguments = null; Assert.IsNotNull(vkr.NamedArguments); Assert.AreEqual(0, vkr.NamedArguments.Count); }
public void InvokeWithMixOfNamedAndPlainVanillaArgumentsOfDifferingTypes() { int maximumAge = 95; string expectedStatus = "Old Age Pensioner"; Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "GrowOlderUntilMaximumAgeReachedAndSetStatusName"; vkr.AddNamedArgument("years", 10); vkr.AddNamedArgument("status", expectedStatus); vkr.Arguments = new object[] { maximumAge }; vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(maximumAge, actual); Assert.AreEqual(expectedStatus, foo.Status); }
public void InvokeWithNamedArgumentThatDoesNotExist() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("southpaw", 10); Assert.Throws <ArgumentException>(() => vkr.Prepare(), "The named argument 'southpaw' could not be found on the 'GrowOlder' method of class [Spring.Objects.Support.MethodInvokerTests+Foo]."); }
public void InvokeWithArgumentOfWrongType() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("years", "Bingo"); vkr.Prepare(); Assert.Throws <MethodInvocationException>(() => vkr.Invoke(), "At least one of the arguments passed to this MethodInvoker was incompatible with the signature of the invoked method."); }
public void InvokeWithArgumentOfWrongType() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("years", "Bingo"); vkr.Prepare(); vkr.Invoke(); }
public void InvokeWithWeIRdLyCasedNamedArgument() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "gROwOldeR"; vkr.AddNamedArgument("YEarS", 10); vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(98, actual); }
public void InvokeWithNamedArgumentThatDoesNotExist() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("southpaw", 10); vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(98, actual); }
public void InvokeWithMixOfNamedAndPlainVanillaArguments() { int maximumAge = 95; Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "GrowOlderUntilMaximumAgeReached"; vkr.AddNamedArgument("years", 10); vkr.Arguments = new object[] { maximumAge }; vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(maximumAge, actual); }
public void NamedArgumentsOverwriteEachOther() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("years", 10); // this second setting must overwrite the first... vkr.AddNamedArgument("years", 200); vkr.Prepare(); object actual = vkr.Invoke(); Assert.IsFalse(98.Equals(actual), "The first named argument setter is sticking; must allow itslf to be overwritten."); Assert.AreEqual(288, actual, "The second named argument was not applied (it must be)."); }
public void InvokeWithArgumentOfWrongType() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("years", "Bingo"); vkr.Prepare(); vkr.Invoke(); }
public void InvokeWithNamedArgument() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("years", 10); vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(98, actual); }
public void InvokeWithMixOfNamedAndPlainVanillaArguments() { int maximumAge = 95; Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "GrowOlderUntilMaximumAgeReached"; vkr.AddNamedArgument("years", 10); vkr.Arguments = new object[] {maximumAge}; vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(maximumAge, actual); }
public void InvokeWithArgumentOfWrongType() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("years", "Bingo"); vkr.Prepare(); Assert.Throws<MethodInvocationException>(() => vkr.Invoke(), "At least one of the arguments passed to this MethodInvoker was incompatible with the signature of the invoked method."); }
public void InvokeWithWeIRdLyCasedNamedArgument() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "gROwOldeR"; vkr.AddNamedArgument("YEarS", 10); vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(98, actual); }
public void InvokeWithNamedArgumentThatDoesNotExist() { Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "growolder"; vkr.AddNamedArgument("southpaw", 10); Assert.Throws<ArgumentException>(() => vkr.Prepare(), "The named argument 'southpaw' could not be found on the 'GrowOlder' method of class [Spring.Objects.Support.MethodInvokerTests+Foo]."); }
public void InvokeWithMixOfNamedAndPlainVanillaArgumentsOfDifferingTypes() { int maximumAge = 95; string expectedStatus = "Old Age Pensioner"; Foo foo = new Foo(); foo.Age = 88; MethodInvoker vkr = new MethodInvoker(); vkr.TargetObject = foo; vkr.TargetMethod = "GrowOlderUntilMaximumAgeReachedAndSetStatusName"; vkr.AddNamedArgument("years", 10); vkr.AddNamedArgument("status", expectedStatus); vkr.Arguments = new object[] {maximumAge}; vkr.Prepare(); object actual = vkr.Invoke(); Assert.AreEqual(maximumAge, actual); Assert.AreEqual(expectedStatus, foo.Status); }