コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
ファイル: ErrorConverterFixture.cs プロジェクト: eslahi/prism
        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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }