public async void FromCurrencyCode_Create_Valid_Reference() { Mock <ICurrencyRateRepository> currencyRateRepository = new Mock <ICurrencyRateRepository>(); currencyRateRepository.Setup(x => x.CurrencyByFromCurrencyCode(It.IsAny <string>())).Returns(Task.FromResult <Currency>(new Currency())); var validator = new ApiCurrencyRateRequestModelValidator(currencyRateRepository.Object); await validator.ValidateCreateAsync(new ApiCurrencyRateRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.FromCurrencyCode, "A"); }
public async void FromCurrencyCode_Update_length() { Mock <ICurrencyRateRepository> currencyRateRepository = new Mock <ICurrencyRateRepository>(); currencyRateRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new CurrencyRate())); var validator = new ApiCurrencyRateRequestModelValidator(currencyRateRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiCurrencyRateRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.FromCurrencyCode, new string('A', 4)); }
public async void FromCurrencyCode_Create_null() { Mock <ICurrencyRateRepository> currencyRateRepository = new Mock <ICurrencyRateRepository>(); currencyRateRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new CurrencyRate())); var validator = new ApiCurrencyRateRequestModelValidator(currencyRateRepository.Object); await validator.ValidateCreateAsync(new ApiCurrencyRateRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.FromCurrencyCode, null as string); }
private async void BeUniqueByCurrencyRateDateFromCurrencyCodeToCurrencyCode_Update_Not_Exists() { Mock <ICurrencyRateRepository> currencyRateRepository = new Mock <ICurrencyRateRepository>(); currencyRateRepository.Setup(x => x.ByCurrencyRateDateFromCurrencyCodeToCurrencyCode(It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult <CurrencyRate>(null)); var validator = new ApiCurrencyRateRequestModelValidator(currencyRateRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiCurrencyRateRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.CurrencyRateDate, DateTime.Parse("1/1/1987 12:00:00 AM")); }
public async void ToCurrencyCode_Update_Invalid_Reference() { Mock <ICurrencyRateRepository> currencyRateRepository = new Mock <ICurrencyRateRepository>(); currencyRateRepository.Setup(x => x.CurrencyByToCurrencyCode(It.IsAny <string>())).Returns(Task.FromResult <Currency>(null)); var validator = new ApiCurrencyRateRequestModelValidator(currencyRateRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiCurrencyRateRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.ToCurrencyCode, "A"); }