public string GetString() { var validatorErrorMessageSource = _propertyValidator.ErrorMessageSource; var globalizedErrorMessage = _errorMessageGlobalizationService.GetErrorMessage(_propertyValidator); Assertion.IsTrue( ReferenceEquals(_propertyValidator.ErrorMessageSource, validatorErrorMessageSource), "ErrorMessageSource of PropertyValidator has been changed by invocation of '{0}'.GetErrorMessage (...).", _errorMessageGlobalizationService.GetType().FullName); return(globalizedErrorMessage ?? _fallbackErrorMessageSource.GetString()); }
public ErrorMessageStringSource( IPropertyValidator propertyValidator, IErrorMessageGlobalizationService errorMessageGlobalizationService, IStringSource fallbackErrorMessageSource) { ArgumentUtility.CheckNotNull("propertyValidator", propertyValidator); ArgumentUtility.CheckNotNull("errorMessageGlobalizationService", errorMessageGlobalizationService); ArgumentUtility.CheckNotNull("fallbackErrorMessageSource", fallbackErrorMessageSource); _propertyValidator = propertyValidator; _errorMessageGlobalizationService = errorMessageGlobalizationService; _fallbackErrorMessageSource = fallbackErrorMessageSource; _resourceName = propertyValidator.GetType().FullName; _resourceType = errorMessageGlobalizationService.GetType(); }
public void Initialization() { Assert.That(_stringSource.ResourceName, Is.EqualTo(_propertyValidator.GetType().FullName)); Assert.That(_stringSource.ResourceType, Is.EqualTo(_validatorGlobalizationServiceMock.GetType())); }