public void AccountDto_is_not_valid(AccountDto dto, string message) { var result = dto.IsValid(); result.Should().BeFalse(); dto.ValidationResult.Errors.Should().NotBeNullOrEmpty(); dto.ValidationResult.Errors.First().ErrorMessage.Should().Be(message); }
public void AccountDto_is_valid() { var dto = new AccountDto { Name = "test", DueDate = DateTime.Now, PaymentDate = DateTime.Now, OriginalValue = 10 }; var result = dto.IsValid(); result.Should().BeTrue(); dto.ValidationResult.Errors.Should().BeNullOrEmpty(); }
public void Add(AccountDto dto) { if (!dto.IsValid()) { NotifyValidationError(dto); return; } (int days, decimal correctedValue, Rule rule) = ApplyRules(dto); var entity = new Account(name: dto.Name, originalValue: dto.OriginalValue.Value, paymentDate: dto.PaymentDate.Value, dueDate: dto.DueDate.Value, correctedValue: correctedValue, rule: rule, numberOfDaysLate: days ); _accountRepository.Add(entity); Commit(); }