Exemple #1
0
 public void SetUp()
 {
     _container = new AutoMocker();
     _container.Use(CreateDamProvider());
     _container.Use(FakeViewModelMapper.CreateFake(typeof(ProductPriceViewService).Assembly));
     _container.Use(CreateLocalizationProvider());
 }
        public async Task WHEN_Passing_Valid_Parameter_SHOULD_Return_Valid_ViewModel()
        {
            var inventoryRepository = new Mock <IInventoryRepository>();

            inventoryRepository.Setup(i => i.FindInventoryItemStatus(It.IsAny <FindInventoryItemStatusParam>()))
            .ReturnsAsync(new List <InventoryItemAvailability> {
                new InventoryItemAvailability
                {
                    Date       = new DateTime(2015, 8, 17),
                    Identifier = new InventoryItemIdentifier
                    {
                        InventoryLocationId = "S001",
                        Sku = "SKU-BIDON"
                    },
                    Statuses = new List <InventoryItemStatus>
                    {
                        new InventoryItemStatus
                        {
                            Quantity = 9999,
                            Status   = InventoryStatus.PreOrder
                        }
                    }
                }
            });

            var viewModelMapper = FakeViewModelMapper.CreateFake(typeof(InventoryViewService).Assembly);

            var inventoryViewService = new InventoryViewService(inventoryRepository.Object, viewModelMapper);
            var viewModel            = await inventoryViewService.FindInventoryItemStatus(new FindInventoryItemStatusParam
            {
                Scope       = "Canada",
                CultureInfo = new CultureInfo("en-CA"),
                Date        = new DateTime(2015, 8, 17),
                Skus        = new List <string>
                {
                    "SKU-BIDOU"
                }
            }).ConfigureAwait(false);

            Assert.IsNotNull(viewModel);
            Assert.That(viewModel.Count == 1);
            Assert.That(viewModel[0].Date == new DateTime(2015, 8, 17));
            Assert.That(viewModel[0].Identifier.InventoryLocationId == "S001");
            Assert.That(viewModel[0].Identifier.Sku == "SKU-BIDON");
            Assert.That(viewModel[0].Statuses.Count == 1);
            Assert.That(viewModel[0].Statuses[0].Quantity == 9999);
            Assert.That(viewModel[0].Statuses[0].Status == InventoryStatusEnum.PreOrder);
        }
        public async Task WHEN_Passing_Empty_Parameter_SHOULD_Return_Empty_ViewModel()
        {
            var inventoryRepository = new Mock <IInventoryRepository>();

            inventoryRepository.Setup(i => i.FindInventoryItemStatus(It.IsAny <FindInventoryItemStatusParam>()))
            .ReturnsAsync(new List <InventoryItemAvailability> {
                new InventoryItemAvailability
                {
                    Date       = DateTime.MinValue,
                    Identifier = new InventoryItemIdentifier
                    {
                        InventoryLocationId = string.Empty,
                        Sku = string.Empty
                    },
                    Statuses = new List <InventoryItemStatus>
                    {
                        new InventoryItemStatus
                        {
                            Quantity = null,
                            Status   = GetRandom.Enumeration <InventoryStatus>()
                        }
                    }
                }
            });

            var viewModelMapper = FakeViewModelMapper.CreateFake(typeof(InventoryViewService).Assembly);

            var inventoryViewService = new InventoryViewService(inventoryRepository.Object, viewModelMapper);
            var viewModel            = await inventoryViewService.FindInventoryItemStatus(new FindInventoryItemStatusParam
            {
                Scope       = string.Empty,
                Date        = DateTime.MinValue,
                CultureInfo = new CultureInfo("en-CA"),
                Skus        = new List <string>
                {
                    string.Empty
                }
            }).ConfigureAwait(false);

            Assert.IsNotNull(viewModel);
            Assert.That(viewModel.Count == 1);
            Assert.That(viewModel[0].Date == DateTime.MinValue);
            Assert.That(viewModel[0].Identifier.InventoryLocationId == string.Empty);
            Assert.That(viewModel[0].Identifier.Sku == string.Empty);
            Assert.That(viewModel[0].Statuses.Count == 1);
            Assert.That(viewModel[0].Statuses[0].Quantity == null);
        }