public void UpdatingValidationSucceeds() { AddUpdateExpenseInfo command = new AddUpdateExpenseInfo() { expenseId = 1, name = "Updated Expense", billedDate = new DateTime(2018, 2, 2) }; List <ValidationResult> results = addUpdateExpenseValidator.Validate(command).ToList(); // Assert Assert.Empty(results); }
public void ExpenseBilledDateIsRequired() { AddUpdateExpenseInfo command = new AddUpdateExpenseInfo() { expenseId = 1, name = "Updated Expense" }; List <ValidationResult> results = addUpdateExpenseValidator.Validate(command).ToList(); // Assert Assert.NotEmpty(results); Assert.Single(results); Assert.Contains(new ValidationResult("BilledDate", "A billed date is required for an expense item"), results); }
public void ExpenseNameIsRequired() { AddUpdateExpenseInfo command = new AddUpdateExpenseInfo() { expenseId = 0, name = null, billedDate = new DateTime(2018, 2, 2) }; List <ValidationResult> results = addUpdateExpenseValidator.Validate(command).ToList(); // Assert Assert.NotEmpty(results); Assert.Single(results); Assert.Contains(new ValidationResult("Name", "Name is required on an expense item"), results); }
public void ExpenseMustExist() { AddUpdateExpenseInfo command = new AddUpdateExpenseInfo() { expenseId = 2, name = "Updated Expense", billedDate = new DateTime(2018, 2, 2) }; List <ValidationResult> results = addUpdateExpenseValidator.Validate(command).ToList(); // Assert Assert.NotEmpty(results); Assert.Single(results); Assert.Contains(new ValidationResult("ID", "No expense exists with the ID: 2"), results); }