Beispiel #1
0
        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);
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        private async void BeUniqueByCurrencyRateDateFromCurrencyCodeToCurrencyCode_Update_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>(new CurrencyRate()));
            var validator = new ApiCurrencyRateRequestModelValidator(currencyRateRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiCurrencyRateRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.CurrencyRateDate, DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
Beispiel #4
0
        public async void FromCurrencyCode_Create_Invalid_Reference()
        {
            Mock <ICurrencyRateRepository> currencyRateRepository = new Mock <ICurrencyRateRepository>();

            currencyRateRepository.Setup(x => x.CurrencyByFromCurrencyCode(It.IsAny <string>())).Returns(Task.FromResult <Currency>(null));

            var validator = new ApiCurrencyRateRequestModelValidator(currencyRateRepository.Object);

            await validator.ValidateCreateAsync(new ApiCurrencyRateRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.FromCurrencyCode, "A");
        }