public async Task WHEN_method_is_invoked_SHOULD_call_repo_for_fulfillment_locations()
        {
            //Arrange
            var p = new GetFulfillmentLocationParam
            {
                Scope = GetRandom.String(6)
            };

            var sut = Container.CreateInstance <ConfigurationInventoryLocationProvider>();

            //Act
            await sut.GetFulfillmentLocationAsync(p);

            //Assert
            Container.Verify <IFulfillmentLocationsRepository>(repo => repo.GetFulfillmentLocationsByScopeAsync(It.IsNotNull <GetFulfillmentLocationsByScopeParam>()));
        }
        public async Task WHEN_method_is_invoked_SHOULD_return_first_valid_fulfillment_location_id()
        {
            //Arrange
            var p = new GetFulfillmentLocationParam
            {
                Scope = GetRandom.String(7)
            };

            var sut = Container.CreateInstance <ConfigurationInventoryLocationProvider>();

            //Act
            var location = await sut.GetFulfillmentLocationAsync(p);

            //Assert
            location.Should().NotBeNull();
            location.Id.Should().Be(ValidLocationId);
        }
Esempio n. 3
0
        public void WHEN_Locations_do_not_contain_default_id_THROWS_InvalidOperationException()
        {
            //Arrange
            var defaultInventoryLocationId = GetRandom.String(6); //Changing the ID between generation of list and execution of SUT.

            SiteConfigurationMock.Setup(s => s.GetInventoryAndFulfillmentLocationId(It.IsAny <Guid>())).Returns(defaultInventoryLocationId);
            var p = new GetFulfillmentLocationParam
            {
                Scope = GetRandom.String(7)
            };

            var sut = Container.CreateInstance <ConfigurationInventoryLocationProvider>();

            //Act
            Expression <Func <Task <FulfillmentLocation> > > expression = () => sut.GetFulfillmentLocationAsync(p);
            var exception = Assert.ThrowsAsync <InvalidOperationException>(() => expression.Compile().Invoke());

            //Assert
            exception.Message.Should().ContainEquivalentOf("Could not find any active fulfillment location in the scope");
        }
Esempio n. 4
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);
        }
        public void WHEN_Locations_do_not_contain_default_id_THROWS_ArgumentException()
        {
            //Arrange
            var defaultInventoryLocationId = GetRandom.String(6); //Changing the ID between generation of list and execution of SUT.

            SiteConfigurationMock.Setup(s => s.GetInventoryAndFulfillmentLocationId(It.IsAny <Guid>())).Returns(defaultInventoryLocationId);
            var p = new GetFulfillmentLocationParam
            {
                Scope = GetRandom.String(7)
            };

            var sut = Container.CreateInstance <ConfigurationInventoryLocationProvider>();

            //Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => sut.GetFulfillmentLocationAsync(p));

            //Assert
            exception.Should().NotBeNull();
            exception.ParamName.ShouldBeEquivalentTo("param");
            exception.Message.Should().ContainEquivalentOf(p.Scope);
            exception.Message.Should().ContainEquivalentOf(defaultInventoryLocationId);
        }
Esempio n. 6
0
        protected virtual GetFulfillmentLocationsByScopeParam GetFulfillmentLocationsByScopeParam(GetFulfillmentLocationParam param)
        {
            var p = new GetFulfillmentLocationsByScopeParam
            {
                Scope = param.Scope,
                IncludeChildScopes = false,
                IncludeSchedules   = false
            };

            return(p);
        }