Esempio n. 1
0
            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);
            }
Esempio n. 2
0
            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);
            }
Esempio n. 3
0
            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);
            }
Esempio n. 4
0
            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);
            }