Exemple #1
0
        public void SetUp()
        {
            _container = new AutoMocker();

            var overtureClient = _container.GetMock <IOvertureClient>();

            overtureClient.Setup(ovClient => ovClient.SendAsync(
                                     It.IsNotNull <GetFulfillmentLocationsByScopeRequest>()))
            .ReturnsAsync(new List <FulfillmentLocation>())
            .Verifiable();

            var cacheProvider = _container.GetMock <ICacheProvider>();

            cacheProvider
            .Setup(provider => provider.GetOrAddAsync(
                       It.IsNotNull <CacheKey>(),
                       It.IsNotNull <Func <Task <List <FulfillmentLocation> > > >(),
                       It.IsAny <Func <List <FulfillmentLocation>, Task> >(),
                       It.IsAny <CacheKey>()))
            .Returns <CacheKey, Func <Task <List <FulfillmentLocation> > >,
                      Func <List <FulfillmentLocation>, Task>, CacheKey>(
                (key, func, arg3, arg4) => func())
            .Verifiable();

            _sut = _container.CreateInstance <FulfillmentLocationsRepository>();
        }
Exemple #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);
        }