示例#1
0
        public void WHEN_Passing_Empty_Skus_THROW_ArgumentException()
        {
            var inventoryRepository = Container.CreateInstance <InventoryRepository>();
            var param = new FindInventoryItemStatusParam
            {
                Scope = GetRandom.String(25),
                Date  = GetRandom.DateTime(),
                Skus  = new List <string>()
            };

            Assert.ThrowsAsync <ArgumentException>(() => inventoryRepository.FindInventoryItemStatus(param));
        }
        public void WHEN_Passing_Empty_Skus_SHOULD_Throw_ArgumentException()
        {
            var inventoryRepository = new Mock <IInventoryRepository>();
            var viewModelMapper     = new Mock <IViewModelMapper>();

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

            Assert.ThrowsAsync <ArgumentException>(() => inventoryViewService.FindInventoryItemStatus(param));
        }
示例#3
0
        /// <summary>
        /// Retrieve the detail about the status of Inventory Items represented by the specified InventoryLocationId and a list of skus for the specified date
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <List <InventoryItemAvailabilityViewModel> > FindInventoryItemStatus(FindInventoryItemStatusParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (param.Scope == null)
            {
                throw new ArgumentNullException("ScopeId");
            }
            if (param.Skus == null)
            {
                throw new ArgumentNullException("Skus");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException("CultureInfo");
            }
            if (param.Skus.Count == 0)
            {
                throw new ArgumentException("Skus is empty");
            }

            var inventoryItemsAvailability = await InventoryRepository.FindInventoryItemStatus(param).ConfigureAwait(false);

            if (inventoryItemsAvailability == null)
            {
                throw new NullReferenceException("Inventory is not properly configured. Make sure Enable Inventory Management is set to True");
            }

            var inventoryItemsAvailabilityViewModel = new List <InventoryItemAvailabilityViewModel>();

            foreach (var inventoryItemAvailability in inventoryItemsAvailability)
            {
                var inventoryItemStatusesViewModel = new List <InventoryItemStatusViewModel>();

                foreach (var inventoryItemStatus in inventoryItemAvailability.Statuses)
                {
                    inventoryItemStatusesViewModel.Add(new InventoryItemStatusViewModel
                    {
                        Quantity = inventoryItemStatus.Quantity,
                        Status   = GetInventoryStatus(inventoryItemStatus.Status)
                    });
                }

                var inventoryItemIdentifierViewModel = ViewModelMapper.MapTo <InventoryItemIdentifierViewModel>(
                    inventoryItemAvailability.Identifier, param.CultureInfo);

                inventoryItemsAvailabilityViewModel.Add(new InventoryItemAvailabilityViewModel
                {
                    Date       = inventoryItemAvailability.Date,
                    Identifier = inventoryItemIdentifierViewModel,
                    Statuses   = inventoryItemStatusesViewModel
                });
            }

            return(inventoryItemsAvailabilityViewModel);
        }
        /// <summary>
        /// Retrieve the detail about the status of Inventory Items represented by the specified InventoryLocationId and a list of skus for the specified date
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <List <InventoryItemAvailability> > FindInventoryItemStatus(FindInventoryItemStatusParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Scope"), "param");
            }
            if (param.Skus == null)
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("Skus"), "param");
            }
            if (param.Skus.Count == 0)
            {
                throw new ArgumentException("Skus is empty", "param");
            }
            if (string.IsNullOrWhiteSpace(param.InventoryLocationId))
            {
                throw new ArgumentException(ArgumentNullMessageFormatter.FormatErrorMessage("InventoryLocationId"), "param");
            }

            var request = new FindInventoryItemStatusByLocationAndSkusRequest
            {
                Date = param.Date,
                InventoryLocationId = param.InventoryLocationId,
                ScopeId             = param.Scope,
                Skus = param.Skus
            };

            var result = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            return(result);
        }
示例#5
0
        /// <summary>
        /// Retrieve the detail about the status of Inventory Items represented by the specified InventoryLocationId and a list of skus for the specified date
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <List <InventoryItemAvailability> > FindInventoryItemStatus(FindInventoryItemStatusParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.Skus == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.Skus)), nameof(param));
            }
            if (param.Skus.Count == 0)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.Skus)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.InventoryLocationId))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.InventoryLocationId)), nameof(param));
            }

            var request = new FindInventoryItemStatusByLocationAndSkusRequest
            {
                Date = param.Date,
                InventoryLocationId = param.InventoryLocationId,
                ScopeId             = param.Scope,
                Skus = param.Skus
            };

            var result = await OvertureClient.SendAsync(request).ConfigureAwait(false);

            return(result);
        }