예제 #1
0
        public void AddValidationError_AddNull_ThrowArgumentNullException()
        {
            ValidationError validationError = null;
              var validationState = new ValidationStatus();

              Assert.Throws<ArgumentNullException>(() => validationState.AddValidationError(validationError));
        }
예제 #2
0
        public void IsValid_ValidErrorsIsEmpty_ReturnTrue()
        {
            var validationState = new ValidationStatus();

              var result = validationState.IsValid;

              Assert.IsTrue(result);
        }
예제 #3
0
        public void ConstructorWithValidationErrors_ValidationErrorsIsNotNull_SetValidationErrors()
        {
            var validationErrors = new List<ValidationError>();

              var validationState = new ValidationStatus(validationErrors);

              Assert.AreSame(validationErrors, validationState.ValidationErrors);
        }
예제 #4
0
        public void IsValid_ValidErrorsIsNot_ReturnFalse()
        {
            var validationState = new ValidationStatus();
              validationState.AddValidationError(new ValidationError("message"));

              var result = validationState.IsValid;

              Assert.IsFalse(result);
        }
예제 #5
0
        public void AddValidationError_AddValidationError_OneValidationErrorInValidetionErrors()
        {
            var validationError = new ValidationError("message");
              var validationState = new ValidationStatus();

              validationState.AddValidationError(validationError);

              Assert.AreEqual(1, validationState.ValidationErrors.ToList().Count);
        }
        public void Dispatch_InvoiceModelIsInvalid_ThrowValidationException()
        {
            var validationStatus = new ValidationStatus(new List<ValidationError> {new ValidationError("error")});
              A.CallTo(() => _validationProcessor.Validate(_command)).Returns(validationStatus);

              Assert.That(() => _validatedCommandDispatcher.Dispatch(_command),
            Throws.InstanceOf<ValidationException>()
            .And.Message.EqualTo(string.Format("Command {0} is incorrect", typeof(ICommand).Name))
            .And.Property("ValidationValidationStatus").SameAs(validationStatus));
        }
 public void ThrowNewValidationException_SetValidationStatus()
 {
     IValidationStatus validationStatus = new ValidationStatus();
       try
       {
     throw new ValidationException("Error", validationStatus);
       }
       catch (ValidationException ex)
       {
     Assert.AreSame(validationStatus, ex.ValidationValidationStatus);
       }
 }
예제 #8
0
        public void Constructor_SetEmptyValidationErrors()
        {
            var validationState = new ValidationStatus();

              Assert.IsEmpty(validationState.ValidationErrors.ToList());
        }