コード例 #1
0
        public async void CurrencyCode_Create_Valid_Reference()
        {
            Mock <ICountryRegionCurrencyRepository> countryRegionCurrencyRepository = new Mock <ICountryRegionCurrencyRepository>();

            countryRegionCurrencyRepository.Setup(x => x.GetCurrency(It.IsAny <string>())).Returns(Task.FromResult <Currency>(new Currency()));

            var validator = new ApiCountryRegionCurrencyRequestModelValidator(countryRegionCurrencyRepository.Object);
            await validator.ValidateCreateAsync(new ApiCountryRegionCurrencyRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.CurrencyCode, "A");
        }
コード例 #2
0
        public async void CurrencyCode_Update_length()
        {
            Mock <ICountryRegionCurrencyRepository> countryRegionCurrencyRepository = new Mock <ICountryRegionCurrencyRepository>();

            countryRegionCurrencyRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new CountryRegionCurrency()));

            var validator = new ApiCountryRegionCurrencyRequestModelValidator(countryRegionCurrencyRepository.Object);
            await validator.ValidateUpdateAsync(default(string), new ApiCountryRegionCurrencyRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.CurrencyCode, new string('A', 4));
        }