public void WHEN_Passing_Valid_Parameters_SHOULD_Succeed()
        {
            //Arrange
            _container.Use(ViewModelMapperFactory.Create());
            _container.Use(CountryRepositoryFactory.Create());

            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.RetrieveRegionsAsync(new RetrieveCountryParam
            {
                IsoCode     = GetRandom.String(32),
                CultureInfo = TestingExtensions.GetRandomCulture(),
            }).Result;

            // Assert
            result.Should().NotBeNull();
        }
Esempio n. 2
0
 public void SetUp()
 {
     Container = new AutoMocker();
     Container.Use(ViewModelMapperFactory.Create());
     Container.Use(LocalizationProviderFactory.Create());
     Container.Use(CartViewModelFactoryMock.Create());
 }
Esempio n. 3
0
        public void SetUp()
        {
            //Arrange
            _container = new AutoMocker();

            _container.Use(ViewModelMapperFactory.Create());
            _container.Use(CartViewModelFactoryMock.Create());

            var cartRepoMock = _container.GetMock <ICartRepository>();

            cartRepoMock.Setup(repo => repo.CompleteCheckoutAsync(It.IsNotNull <CompleteCheckoutParam>()))
            .Returns((CompleteCheckoutParam p) =>
            {
                var order = new Overture.ServiceModel.Orders.Order
                {
                    Cart = new ProcessedCart()
                    {
                        Customer = new CustomerSummary()
                        {
                            Email = GetRandom.Email()
                        },
                        Shipments = new System.Collections.Generic.List <Shipment>()
                        {
                            new Shipment
                            {
                                Id        = GetRandom.Guid(),
                                LineItems = new System.Collections.Generic.List <LineItem>()
                                {
                                    new LineItem
                                    {
                                        Id               = GetRandom.Guid(),
                                        Sku              = GetRandom.String(10),
                                        CatalogId        = GetRandom.String(10),
                                        PlacedPrice      = GetRandom.Decimal(),
                                        PlacedQuantity   = GetRandom.Int(),
                                        Status           = GetRandom.String(5),
                                        Total            = GetRandom.Decimal(),
                                        KvaValues        = new Overture.ServiceModel.PropertyBag(),
                                        KvaDisplayValues = new Overture.ServiceModel.PropertyBag(),
                                        ProductSummary   = new CartProductSummary
                                        {
                                            Brand                   = null,
                                            DisplayName             = GetRandom.String(10),
                                            PrimaryParentCategoryId = GetRandom.String(10)
                                        }
                                    }
                                },
                                FulfillmentMethod = new FulfillmentMethod
                                {
                                    FulfillmentMethodType = FulfillmentMethodType.PickUp
                                }
                            }
                        }
                    },
                    OrderNumber = GetRandom.String(12)
                };

                return(Task.FromResult(order));
            });
        }
        public void SetUp()
        {
            //Arrange
            _container = new AutoMocker();

            _container.Use(ViewModelMapperFactory.Create());
            _container.Use(CartRepositoryFactory.Create());
            _container.Use(CartViewModelFactoryMock.Create());
            _container.Use(CountryServiceMock.Create());
            _container.Use(LocalizationProviderFactory.Create());
        }
Esempio n. 5
0
        public void SetUp()
        {
            //Arrange
            _container = new AutoMocker();

            _container.Use(ViewModelMapperFactory.Create());
            _container.Use(CartRepositoryFactory.Create());
            _container.Use(CartViewModelFactoryMock.Create());
            _container.Use(CountryServiceMock.Create());
            _container.Use <IFixCartService>(new FakeFixCartService());

            var localizationProviderMock = new Mock <ILocalizationProvider>();

            localizationProviderMock
            .Setup(c => c.GetLocalizedString(It.IsAny <GetLocalizedParam>()))
            .Returns("{0}");
        }
        public void WHEN_CultureInfo_Is_Null_SHOULD_Throw_ArgumentException()
        {
            // Arrange
            _container.Use(ViewModelMapperFactory.Create());
            _container.Use(CountryRepositoryFactory.Create());
            var service = _container.CreateInstance <CountryService>();

            var param = new RetrieveCountryParam
            {
                IsoCode = GetRandom.String(32),
            };

            // Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => service.RetrieveRegionsAsync(param));

            //Assert
            exception.ParamName.Should().BeSameAs("param");
        }
        public void WHEN_IsoCode_Is_NullOrWhitespace_SHOULD_Throw_ArgumentException(string isoCode)
        {
            //Arrange
            _container.Use(ViewModelMapperFactory.Create());
            _container.Use(CountryRepositoryFactory.Create());
            var service = _container.CreateInstance <CountryService>();
            var param   = new RetrieveCountryParam
            {
                IsoCode     = isoCode,
                CultureInfo = TestingExtensions.GetRandomCulture()
            };

            // Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => service.RetrieveRegionsAsync(param));

            //Assert
            exception.ParamName.Should().BeSameAs("param");
        }