public void CallGenericMethodByName_is_correct() { var obj = new TypeWithMethod(); var type = obj.GetType(); const string text = "test"; type.CallGenericMethodByName(obj, nameof(TypeWithMethod.GenericCast), typeof(string).PackIntoArray(), text); }
public void CallMethodByName_throws_exception_for_generic_method() { var obj = new TypeWithMethod(); var type = obj.GetType(); const string text = "test"; Assert.Throws <lib12Exception>(() => type.CallMethodByName(obj, nameof(TypeWithMethod.GenericCast), text)); }
public void CallMethodByName_is_correct_for_method_without_result() { var obj = new TypeWithMethod(); var type = obj.GetType(); var result = type.CallMethodByName(obj, nameof(TypeWithMethod.Empty)); result.ShouldBe(null); }
public void CallGenericMethodByName_throws_exception_when_incorrect_number_of_type_arguments_is_provided() { var obj = new TypeWithMethod(); var type = obj.GetType(); const string text = "test"; var typeArgs = Pack.IntoArray(typeof(string), typeof(int)); Assert.Throws <ArgumentException>(() => type.CallGenericMethodByName(obj, nameof(TypeWithMethod.GenericCast), typeArgs, text)); }
public void CallMethodByName_is_correct_for_private_static_method() { var obj = new TypeWithMethod(); var type = obj.GetType(); var result = type.CallMethodByName(obj, "PrivateStatic"); result.ShouldBeOfType <int>(); result.ShouldBe(12); }
public void ResolveMethodTest() { Container c = new Container(); c.AddSingleton(() => new TypeWithMethod()); c.AddSingleton(() => new GuessableType()); TypeWithMethod t = c.GetInstance <TypeWithMethod>(); Assert.True(t.gotCalled); }
public void CallMethodByName_is_correct_for_method_with_result() { const int number1 = 5; const int number2 = 7; var obj = new TypeWithMethod(); var type = obj.GetType(); var result = type.CallMethodByName(obj, nameof(TypeWithMethod.Add), number1, number2); result.ShouldBeOfType <int>(); result.ShouldBe(12); }