public void GetClientValidationRulesReturnsModelClientValidationEqualToRule() {

            Mock<ModelMetadataProvider> provider = new Mock<ModelMetadataProvider>();
            Mock<ModelMetadata> metadata = new Mock<ModelMetadata>(provider.Object, null, null, typeof(string), null);
            metadata.Setup(m => m.DisplayName).Returns("CurrentProperty");

            CompareAttribute attr = new CompareAttribute("CompareProperty");
            List<ModelClientValidationRule> ruleList = new List<ModelClientValidationRule>(attr.GetClientValidationRules(metadata.Object, null));

            Assert.AreEqual(ruleList.Count, 1);

            ModelClientValidationEqualToRule actualRule = ruleList[0] as ModelClientValidationEqualToRule;

            Assert.AreEqual(actualRule.ErrorMessage, "'CurrentProperty' and 'CompareProperty' do not match.", "*.CompareProperty");
            Assert.AreEqual(actualRule.ValidationType, "equalto");
            Assert.AreEqual(actualRule.ValidationParameters["other"], "*.CompareProperty");
        }
        public void ModelClientValidationEqualToRuleUsesSetDisplayName()
        {
            Mock<ModelMetadataProvider> provider = new Mock<ModelMetadataProvider>();
            ModelMetadata metadata = new ModelMetadata(provider.Object, typeof(CompareObject), null, typeof(string), null);
            metadata.DisplayName = "CurrentProperty";

            CompareAttribute attr = new CompareAttribute("ComparePropertyWithDisplayName");
            attr.OtherPropertyDisplayName = "SetDisplayName";

            List<ModelClientValidationRule> ruleList = new List<ModelClientValidationRule>(attr.GetClientValidationRules(metadata, null));
            Assert.Equal(ruleList.Count, 1);
            ModelClientValidationEqualToRule actualRule = ruleList[0] as ModelClientValidationEqualToRule;

            Assert.Equal("'CurrentProperty' and 'SetDisplayName' do not match.", actualRule.ErrorMessage);
        }