예제 #1
0
        public void WHEN_param_is_null_SHOULD_throw_ArgumentNullException()
        {
            //Arrange
            GetFulfillmentLocationsByScopeParam p = null;

            //Act
            var exception = Assert.ThrowsAsync <ArgumentNullException>(() => _sut.GetFulfillmentLocationsByScopeAsync(p));

            //Assert
            exception.Should().NotBeNull();
            exception.ParamName.ShouldBeEquivalentTo("param");
        }
예제 #2
0
        /// <summary>
        /// Obtains the fulfillment location to use for a cart.
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public virtual async Task <FulfillmentLocation> GetFulfillmentLocationAsync(GetFulfillmentLocationParam param)
        {
            var p = GetFulfillmentLocationsByScopeParam(param);

            var getLocationsTask = FulfillmentLocationsRepository.GetFulfillmentLocationsByScopeAsync(p);
            //TODO: See Bug #6064 - The search crash when inventory is disabled and the fulfillment location is wrong
            var getDefaultLocationIdTask = GetDefaultInventoryLocationIdAsync();
            await Task.WhenAll(getLocationsTask, getDefaultLocationIdTask).ConfigureAwait(false);

            var locations         = await getLocationsTask;
            var defaultLocationId = await getDefaultLocationIdTask;

            var location = GetMatchingLocation(locations, defaultLocationId);

            if (location == null)
            {
                throw new ArgumentException(string.Format("Could not find any active fulfillment location in the scope '{0}' to support the Inventory Location Id '{1}'",
                                                          param.Scope, defaultLocationId), "param");
            }

            return(location);
        }