Skip to content

Commit

Permalink
Test fixed - expression is also serialized to json now (because of th…
Browse files Browse the repository at this point in the history
…at the code is slightly simplified at client-side).
  • Loading branch information
jwaliszko committed Aug 26, 2015
1 parent afc74f1 commit e3fdbbe
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,15 @@ public void client_validation_rules_are_json_formatting_insensitive()

Assert.AreEqual("{\"Value\":\"numeric\",\"Status\":\"numeric\"}", (string)assertRule.ValidationParameters["fieldsmap"], false, CultureInfo.InvariantCulture);
Assert.AreEqual("{\"ValidatorsTest.State.High\":0}", (string)assertRule.ValidationParameters["constsmap"], false, CultureInfo.InvariantCulture);
// expression is not a json actually, but tested for the sake of clarity
Assert.AreEqual("Value > 0 && Status == ValidatorsTest.State.High", (string)assertRule.ValidationParameters["expression"], false, CultureInfo.InvariantCulture);
Assert.AreEqual("\"Value > 0 && Status == ValidatorsTest.State.High\"", (string)assertRule.ValidationParameters["expression"], false, CultureInfo.InvariantCulture);

var requir = new RequiredIfValidator(metadata, controllerContext, new RequiredIfAttribute("Value > 0 && Status == ValidatorsTest.State.High"));
var requirRule = requir.GetClientValidationRules().Single();

Assert.AreEqual("{\"Value\":\"numeric\",\"Status\":\"numeric\"}", (string)requirRule.ValidationParameters["fieldsmap"], false, CultureInfo.InvariantCulture);
Assert.AreEqual("{\"ValidatorsTest.State.High\":0}", (string)requirRule.ValidationParameters["constsmap"], false, CultureInfo.InvariantCulture);
Assert.AreEqual("false", (string)requirRule.ValidationParameters["allowempty"], false, CultureInfo.InvariantCulture);
// expression is not a json actually, but tested for the sake of clarity
Assert.AreEqual("Value > 0 && Status == ValidatorsTest.State.High", (string)requirRule.ValidationParameters["expression"], false, CultureInfo.InvariantCulture);
Assert.AreEqual("\"Value > 0 && Status == ValidatorsTest.State.High\"", (string)requirRule.ValidationParameters["expression"], false, CultureInfo.InvariantCulture);

JsonConvert.DefaultSettings = settings; // reset settings to original state
}
Expand Down

0 comments on commit e3fdbbe

Please sign in to comment.