public void NotDuplicateExpenseDetailsValidation() { var aExpenseValidator = this.valFactoryFromConfig.CreateValidator <Model.Expense>("ExpenseRuleset"); var expenseToValidate = StubsHelper.GenerateExpenseStub(); expenseToValidate.Details = new List <Model.ExpenseItem> { new Model.ExpenseItem() { Description = "Test" }, new Model.ExpenseItem() { Description = "Test" } }; ValidationResults results = aExpenseValidator.Validate(expenseToValidate); Assert.IsFalse(results.IsValid); Assert.AreEqual(1, results.Count); var result = results.FirstOrDefault(); Assert.IsNotNull(result); StringAssert.Equals(Resources.DuplicateExpenseDetailsValidation, result.Message); }
public void ExpenseIsOkValidationPasses() { var aExpenseValidator = this.valFactory.CreateValidator <Model.Expense>(); var expenseToValidate = StubsHelper.GenerateExpenseStub(); ValidationResults results = aExpenseValidator.Validate(expenseToValidate); Assert.IsTrue(results.IsValid); Assert.AreEqual(0, results.Count); }
public void UserShouldNotBeNullValidation() { var aExpenseValidator = this.valFactory.CreateValidator <Model.Expense>(); var expenseToValidate = StubsHelper.GenerateExpenseStub(); expenseToValidate.User = null; ValidationResults results = aExpenseValidator.Validate(expenseToValidate); Assert.IsFalse(results.IsValid); Assert.AreEqual(1, results.Count); var result = results.FirstOrDefault(); Assert.IsNotNull(result); StringAssert.Equals(Resources.UserNotNullMessage, result.Message); }
public void TitleMustBeSuppliedValidation() { var aExpenseValidator = this.valFactory.CreateValidator <Model.Expense>(); var expenseToValidate = StubsHelper.GenerateExpenseStub(); expenseToValidate.Title = string.Empty; ValidationResults results = aExpenseValidator.Validate(expenseToValidate); Assert.IsFalse(results.IsValid); Assert.AreEqual(1, results.Count); var result = results.FirstOrDefault(); Assert.IsNotNull(result); StringAssert.Equals(Resources.TitleMustBeSuppliedMessage, result.Message); }
public void AmountMustBePositiveValidation() { var aExpenseItemValidator = this.valFactory.CreateValidator <Model.ExpenseItem>(); var expenseItemToValidate = StubsHelper.GenerateExpenseItemStub(); expenseItemToValidate.Amount = -1; ValidationResults results = aExpenseItemValidator.Validate(expenseItemToValidate); Assert.IsFalse(results.IsValid); Assert.AreEqual(1, results.Count); var result = results.FirstOrDefault(); Assert.IsNotNull(result); StringAssert.Equals(Resources.AmountGreaterThanZeroMessage, result.Message); }