public void SetUp() { this.bidValidator = new BidValidator(); this.anotherBid = new Bid { Id = 1, Amount = 10, Date = DateTime.Now.AddDays(-1) }; this.bid = new Bid { Id = 2, Amount = 10, Date = DateTime.Now, Product = new Product { Id = 1, StartDate = DateTime.Now.AddDays(1), EndDate = DateTime.Now.AddDays(10), Name = "Valid Name for Product", Currency = new Currency { Name = "ValidCurrency", Abbreviation = "VC" }, Price = 10, Description = "This is a valid despription of a valid product because it has a valid lenght.", Bid = new List <Bid> { this.anotherBid } } }; }
public ValidationResult ValidateResource(EditBidResource resource) { var result = new ValidationResult(); if (resource != null) { var validator = new BidValidator(); var vr = validator.Validate(resource); if (vr.IsValid) { result.IsValid = true; return(result); } if (vr.Errors.Any()) { foreach (var error in vr.Errors) { result.ErrorMessages.Add(error.PropertyName, error.ErrorMessage); } } } return(result); }