public void WHEN_parameters_ok_SHOULD_return_notnull_CartViewModel()
        {
            //Arrange
            UseCountryServiceMock();

            var p = new CreateCartViewModelParam
            {
                Cart             = new Overture.ServiceModel.Orders.Cart(),
                CultureInfo      = CultureInfo.InvariantCulture,
                BaseUrl          = GetRandom.String(32),
                ProductImageInfo = new ProductImageInfo
                {
                    ImageUrls = new List <ProductMainImage>()
                }
            };

            Container.Use(ViewModelMapperFactory.CreateViewNullValues());
            var sut = Container.CreateInstance <CartViewModelFactory>();

            //Act
            var vm = sut.CreateCartViewModel(p);

            //Assert
            vm.Should().NotBeNull();
        }
        public void WHEN_country_postal_code_regex_is_not_null_or_empty_SHOULD_set_postal_code_regex_in_billing_address()
        {
            //Arrange
            UseCountryServiceMock();

            var p = new CreateCartViewModelParam
            {
                Cart             = new Overture.ServiceModel.Orders.Cart(),
                CultureInfo      = CultureInfo.InvariantCulture,
                BaseUrl          = GetRandom.String(32),
                ProductImageInfo = new ProductImageInfo
                {
                    ImageUrls = new List <ProductMainImage>()
                }
            };

            Container.Use(ViewModelMapperFactory.CreateViewNullValues());
            var sut = Container.CreateInstance <CartViewModelFactory>();

            //Act
            var vm = sut.CreateCartViewModel(p);

            //Assert
            vm.Payment.BillingAddress.PostalCodeRegexPattern.Should().Be(ExpectedPostalCodeRegex);
        }
예제 #3
0
        public void WHEN_Dependencies_Return_NullValues_SHOULD_Succeed()
        {
            //Arrange
            _container.Use(ViewModelMapperFactory.CreateViewNullValues());
            _container.Use(CountryRepositoryFactory.CreateWithNullValues());

            var localizationProviderMock = new Mock <ILocalizationProvider>();

            localizationProviderMock
            .Setup(c => c.GetLocalizedString(It.IsAny <GetLocalizedParam>()))
            .Returns("{0}");

            _container.Use(localizationProviderMock);

            var service = _container.CreateInstance <CountryService>();

            // Act
            var result = service.RetrieveCountryAsync(new RetrieveCountryParam
            {
                IsoCode     = GetRandom.String(32),
                CultureInfo = TestingExtensions.GetRandomCulture()
            }).Result;

            // Assert
            result.Should().NotBeNull();
        }