public void Method_with_wrong_parameter_does_not_match(Check check) { var analyzer = new MethodAnalyzer(); bool isMatch = check == Check.RequestAndResponse ? analyzer.IsMatch(_echoStringInspection, typeof(int), typeof(string), false, out var match) : analyzer.IsMatch(_echoStringInspection, typeof(int), false, out match); Assert.False(isMatch); Assert.Null(match); }
public void Method_with_parameters_returning_result_matches(Check check) { var analyzer = new MethodAnalyzer(); bool isMatch = check == Check.RequestAndResponse ? analyzer.IsMatch(_echoStringInspection, typeof(string), typeof(string), false, out var match) : analyzer.IsMatch(_echoStringInspection, typeof(string), false, out match); Assert.True(isMatch); Assert.NotNull(match); Assert.Equal(typeof(SomeTypeWithManyMethods).GetMethod(nameof(SomeTypeWithManyMethods.EchoString)), match); }
public void Method_with_parameters_returning_void_matches(Check check) { var analyzer = new MethodAnalyzer(); bool isMatch = check == Check.RequestAndResponse ? analyzer.IsMatch(_acceptIntVoidInspection, typeof(int), typeof(void), false, out var match) : analyzer.IsMatch(_acceptIntVoidInspection, typeof(int), false, out match); Assert.True(isMatch); Assert.NotNull(match); Assert.Equal(typeof(SomeTypeWithManyMethods).GetMethod(nameof(SomeTypeWithManyMethods.AcceptIntVoid)), match); }
public void Method_returning_generic_task_matches(Check check) { var analyzer = new MethodAnalyzer(); bool isMatch = check == Check.RequestAndResponse ? analyzer.IsMatch(_returnTaskInspection, typeof(int), typeof(Task <int>), false, out var match) : analyzer.IsMatch(_returnTaskInspection, typeof(int), false, out match); Assert.True(isMatch); Assert.NotNull(match); Assert.Equal(typeof(SomeTypeWithManyMethods).GetMethod(nameof(SomeTypeWithManyMethods.ReturnTask)), match); }
public void Method_returning_valuetask_does_not_return_void() { var analyzer = new MethodAnalyzer(); bool isMatch = analyzer.IsMatch(_doValueTaskInspection, typeof(void), typeof(void), false, out var match); Assert.False(isMatch); Assert.Null(match); }
public void Generic_task_does_not_equal_task() { var analyzer = new MethodAnalyzer(); bool isMatch = analyzer.IsMatch(_returnTaskInspection, typeof(int), typeof(Task), false, out var match); Assert.False(isMatch); Assert.Null(match); }
public void Method_returning_void_matches() { var analyzer = new MethodAnalyzer(); bool isMatch = analyzer.IsMatch(_doVoidInspection, typeof(void), typeof(void), false, out var match); Assert.True(isMatch); Assert.NotNull(match); Assert.Equal(typeof(SomeTypeWithManyMethods).GetMethod(nameof(SomeTypeWithManyMethods.DoVoid)), match); }