Beispiel #1
0
        public async Task TestAddressValidation(Address address, bool expectedIsValid)
        {
            const string storeId = "some-test-store";

            // Arrange
            var storeService             = new Mock <IStoreService>();
            var taxProviderSearchService = new Mock <ITaxProviderSearchService>();

            var taxProviderSearchCriteria = new TaxProviderSearchCriteria
            {
                StoreIds = new[] { storeId },
                Keyword  = typeof(AvaTaxRateProvider).Name
            };

            taxProviderSearchService.Setup(x => x.SearchTaxProvidersAsync(taxProviderSearchCriteria)).ReturnsAsync(new TaxProviderSearchResult
            {
                TotalCount = 1,
                Results    = new List <TaxProvider>
                {
                    new AvaTaxRateProvider
                    {
                        IsActive = true,
                        Settings = Settings
                    }
                }
            });

            storeService.Setup(x => x.GetByIdAsync(storeId, null)).ReturnsAsync(new Store
            {
                Id = storeId
            });

            var options = new Mock <IOptions <AvaTaxSecureOptions> >();

            options.Setup(x => x.Value).Returns(Options);

            var target = new AddressValidationService(storeService.Object, CreateAvaTaxClient, taxProviderSearchService.Object, options.Object);

            // Act
            var result = await target.ValidateAddressAsync(address, storeId);

            // Assert
            Assert.Equal(expectedIsValid, result.AddressIsValid);
        }