public void WhenMessageServiceReturnsNamedValue_ValidationMessageIsSet() { // arrange string validationMessage = "This is the correct message"; // message service var mockService = new Mock <IValidationMessageService>(); mockService.Setup(ms => ms.GetValue(It.IsAny <string>(), string.Empty)).Returns(validationMessage); DependencyResolverHelper.SetValidationMessageServiceIntoResolver(mockService); // Act var requiredAttribute = new UmbracoRequiredAttribute("asdf"); // Assert Assert.AreEqual(validationMessage, requiredAttribute.ErrorMessage); }
public void WhenMessageServiceReturnsEmptyValue_DefaultValidatorMessageIsSet() { // arrange string validationMessage = string.Empty; string defaultKeyValidationMessage = string.Empty; // message service var mockService = new Mock <IValidationMessageService>(); mockService.Setup(ms => ms.GetValue(It.IsAny <string>(), string.Empty)).Returns(validationMessage); DependencyResolverHelper.SetValidationMessageServiceIntoResolver(mockService); // Act var requiredAttribute = new UmbracoRequiredAttribute("asdf", "adsfasdf"); var standardRequiredAttribute = new RequiredAttribute(); // Assert Assert.IsNotEmpty(requiredAttribute.ErrorMessage); Assert.AreEqual(standardRequiredAttribute.ErrorMessage, requiredAttribute.ErrorMessage); }