示例#1
0
        public async void FromCurrencyCode_Create_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.ValidateCreateAsync(new ApiCurrencyRateRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.FromCurrencyCode, new string('A', 4));
        }
示例#2
0
        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");
        }
示例#3
0
        private async void BeUniqueByCurrencyRateDateFromCurrencyCodeToCurrencyCode_Create_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.ValidateCreateAsync(new ApiCurrencyRateRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.CurrencyRateDate, DateTime.Parse("1/1/1987 12:00:00 AM"));
        }