Esempio n. 1
0
        public void ShouldReturnEmptyStringIfValueIsNull()
        {
            ErrorConverter converter = new ErrorConverter();
            object         errors    = null;

            object result = converter.Convert(errors, null, null, null);

            Assert.AreEqual(string.Empty, result);
        }
Esempio n. 2
0
        public void ShouldReturnEmptyStringIfCollectionIsEmpty()
        {
            ErrorConverter converter = new ErrorConverter();

            List <ValidationError> errors = new List <ValidationError>();

            object result = converter.Convert(errors.AsReadOnly(), null, null, null);

            Assert.AreEqual(string.Empty, result);
        }
Esempio n. 3
0
        public void ShouldReturnEmptyStringIfCollectionIsEmpty()
        {
            ErrorConverter converter = new ErrorConverter();

            ObservableCollection <ValidationError> value = new ObservableCollection <ValidationError>();

            object result = converter.Convert(value, null, null, null);

            Assert.AreEqual(string.Empty, result);
        }
Esempio n. 4
0
        public void ShouldReturnTheErrorContentOfTheFirstItemInTheCollection()
        {
            ErrorConverter converter = new ErrorConverter();

            List <ValidationError> errors = new List <ValidationError>();
            ValidationError        error  = new ValidationError(new ExceptionValidationRule(), new object());

            error.ErrorContent = "TestError";
            errors.Add(error);

            object result = converter.Convert(errors.AsReadOnly(), null, null, null);

            Assert.AreEqual("TestError", result);
        }
Esempio n. 5
0
        public void ShouldReturnTheInnerExceptionMessageOfATargetInvocationException()
        {
            ErrorConverter converter = new ErrorConverter();

            List <ValidationError> errors = new List <ValidationError>();
            ValidationError        error  = new ValidationError(new ExceptionValidationRule(), new object());

            error.Exception = new TargetInvocationException(null, new Exception("TestError"));
            errors.Add(error);

            object result = converter.Convert(errors.AsReadOnly(), null, null, null);

            Assert.AreEqual("TestError", result);
        }