public void AddValidationError_AddNull_ThrowArgumentNullException() { ValidationError validationError = null; var validationState = new ValidationStatus(); Assert.Throws<ArgumentNullException>(() => validationState.AddValidationError(validationError)); }
public void IsValid_ValidErrorsIsEmpty_ReturnTrue() { var validationState = new ValidationStatus(); var result = validationState.IsValid; Assert.IsTrue(result); }
public void ConstructorWithValidationErrors_ValidationErrorsIsNotNull_SetValidationErrors() { var validationErrors = new List<ValidationError>(); var validationState = new ValidationStatus(validationErrors); Assert.AreSame(validationErrors, validationState.ValidationErrors); }
public void IsValid_ValidErrorsIsNot_ReturnFalse() { var validationState = new ValidationStatus(); validationState.AddValidationError(new ValidationError("message")); var result = validationState.IsValid; Assert.IsFalse(result); }
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); } }
public void Constructor_SetEmptyValidationErrors() { var validationState = new ValidationStatus(); Assert.IsEmpty(validationState.ValidationErrors.ToList()); }