public void MethodParamValidator_Should_Validate_Disallowed_Params() { const string source = @"using System; public class Test { public void DateTime1(DateTime param){} public void F(float param){} }"; var typeDefinition = CompileToTypeDef(source); foreach (var methodDefinition in typeDefinition.Methods) { var result = new MethodParamValidator().Validate(methodDefinition).ToList(); Assert.True(result.All(r => r is MethodParamValidator.MethodParamValidationResult)); } }
public void MethodParamValidator_Should_Validate_Optional_Params() { const string source = @" using System; public class Test { public void OptionalTest(int optional = 1, int optional2 = 2){} }"; var typeDefinition = CompileToTypeDef(source); var method = typeDefinition.Methods.First(m => m.Name == "OptionalTest"); var result = new MethodParamValidator().Validate(method).ToList(); Assert.Equal(2, result.Count); Assert.True(result.All(r => r is MethodParamValidator.MethodParamValidationResult)); }