public void InvokeThrowsErrorIfMemberHasInvalidFormat() { var invoker = new SimpleDynamicInvoker(); Assert.Throws <ArgumentNullException>(() => invoker.Invoke(this, null)); Assert.Throws <ArgumentException>(() => invoker.Invoke(this, "")); Assert.Throws <ArgumentException>(() => invoker.Invoke(this, " broken ")); }
public void InvokeCallsTheMatchingMethod() { var invoker = new SimpleDynamicInvoker(); var result = invoker.Invoke(this, nameof(MatchArgumentMethod), new object[] { "100", false }); Assert.AreEqual(102, result); }
public void InvokeReturnsNullForNonExistentMethod() { var invoker = new SimpleDynamicInvoker(); var result = invoker.Invoke(this, "Fake"); Assert.IsNull(result); }
public void InvokeFailsToMatchWithImpreciseArguments2() { var invoker = new SimpleDynamicInvoker(); var result = invoker.Invoke(this, nameof(MatchArgumentMethod), new object[] { "arg1", 1 }); Assert.IsNull(result); }
public void InvokeThrowsErrorIfArgsCountGreaterThanFourteen() { var invoker = new SimpleDynamicInvoker(); var args = Enumerable.Range(0, 15).Cast <object>().ToArray(); Assert.Throws <ArgumentOutOfRangeException>(() => invoker.Invoke(this, "property", args)); }
public void InvokeCallsTheFullArgumentMethod() { var invoker = new SimpleDynamicInvoker(); var args = new object[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14" }; var result = invoker.Invoke( this, nameof(FullArgumentMethod), args); Assert.AreEqual(string.Join("-", args), result); }
public void InvokeLeaksException() { var invoker = new SimpleDynamicInvoker(); Assert.Throws <ArgumentException>(() => invoker.Invoke(this, nameof(ThrowException))); }
public void InvokeReturnsNullIfObjectIsNull() { var invoker = new SimpleDynamicInvoker(); Assert.IsNull(invoker.Invoke(null, "property")); }