public void ExecuteGenericMethod_CallNotExistingMethod_ThrowsException() { var instance = new GenericMethodTestClass(); Assert.Throws <MissingMethodException>(() => instance.ExecuteGenericMethod("NotExisting", new[] { new GenericArgument("T", typeof(int)) }, 1234)); Assert.Throws <MissingMethodException>(() => instance.ExecuteGenericMethod <string>(nameof(GenericMethodTestClass.GetData), new[] { new GenericArgument("T2", typeof(int)), new GenericArgument("T3", typeof(DateTime)) }, 123, 345)); }
public void ExecuteGenericMethod_CallMethodWithResultAndType_MethodReturnsResult() { const int value = 12345; var instance = new GenericMethodTestClass(); var result = instance.ExecuteGenericMethod <int>(nameof(GenericMethodTestClass.GetData), new[] { typeof(int) }, value); Assert.Equal(value, result); }
public void ExecuteGenericMethod_CallVoidMethodWithType_MethodWasCalled() { const int value = 1234; var instance = new GenericMethodTestClass(); instance.ExecuteGenericMethod(nameof(GenericMethodTestClass.DoSomething), new[] { typeof(int) }, value); Assert.Equal(value.ToString(), instance.Data); }
public void ExecuteGenericMethod_CallMethodWithResultAndTwoGenericTypeParametersAndTypeNotExactlyMatching_MethodReturnsResult() { var value = new TestDataClassSpecial(); var dateTime = DateTime.Now; var instance = new GenericMethodTestClass(); var result = instance.ExecuteGenericMethod <string>(nameof(GenericMethodTestClass.GetData), new[] { typeof(TestDataClassBase), typeof(DateTime) }, value, dateTime); Assert.Equal(value.ToString() + dateTime, result); }
public void ExecuteGenericMethod_CallMethodWithResultAndTwoGenericTypeParametersAndType_MethodReturnsResult() { const int value = 12345; var dateTime = DateTime.Now; var instance = new GenericMethodTestClass(); var result = instance.ExecuteGenericMethod <string>(nameof(GenericMethodTestClass.GetData), new[] { typeof(int), typeof(DateTime) }, value, dateTime); Assert.Equal(value.ToString() + dateTime, result); }