public void CustomRule_Takes_JavaScriptFunction_Params_And_ErrorMessage_Resource_Info() { var jsParam = new { key = "value", another = "something else" }; var rule = new CustomRule("myJsFunction", jsParam, typeof(MyResources), "SomeMessage"); var parameters = rule.ListParameters(); Assert.Equal(2, parameters.Count); Assert.Equal("myJsFunction", parameters["Function"]); Assert.Equal(@"{""key"":""value"",""another"":""something else""}", parameters["Parameters"]); Assert.Equal("Hello from MyResources", rule.ErrorMessageOrResourceString); }
public void CustomRule_Takes_JavaScriptFunction_Params_And_ErrorMessageAccessor() { var jsParam = new { key = "value", another = "something else" }; string error = ""; Func<string> errorAccessor = () => error; var rule = new CustomRule("myJsFunction", jsParam, errorAccessor); var parameters = rule.ListParameters(); Assert.Equal(2, parameters.Count); Assert.Equal("myJsFunction", parameters["Function"]); Assert.Equal(@"{""key"":""value"",""another"":""something else""}", parameters["Parameters"]); error = "Updated error"; Assert.Equal("Updated error", rule.ErrorMessageOrResourceString); }