Пример #1
0
        /// <summary>
        /// Retrieves the list of carts belonging to a customer
        ///
        /// param.IncludeChildScopes is optional
        /// A value indicating whether to include carts found in child scopes.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>List of Cart Summaries</returns>
        public virtual Task <List <CartSummary> > GetCartsByCustomerIdAsync(GetCartsByCustomerIdParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param", "param is required");
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException("param.Scope is required", "param");
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException("param.CultureInfo is required", "param");
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException("param.CustomerId is required", "param");
            }

            var request = new GetCartsByCustomerIdRequest
            {
                CultureName        = param.CultureInfo.Name,
                CustomerId         = param.CustomerId,
                ScopeId            = param.Scope,
                IncludeChildScopes = param.IncludeChildScopes,
            };

            return(OvertureClient.SendAsync(request));
        }
Пример #2
0
        /// <summary>
        /// Retrieves the list of carts belonging to a customer
        ///
        /// param.IncludeChildScopes is optional
        /// A value indicating whether to include carts found in child scopes.
        /// </summary>
        /// <param name="param"></param>
        /// <returns>List of Cart Summaries</returns>
        public virtual Task <List <CartSummary> > GetCartsByCustomerIdAsync(GetCartsByCustomerIdParam 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.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }

            var request = new GetCartsByCustomerIdRequest
            {
                CultureName        = param.CultureInfo.Name,
                CustomerId         = param.CustomerId,
                ScopeId            = param.Scope,
                IncludeChildScopes = param.IncludeChildScopes,
                CartType           = param.CartType
            };

            return(OvertureClient.SendAsync(request));
        }
        public void WHEN_CultureInfo_Is_Null_SHOULD_Throw_ArgumentException()
        {
            //Arrange
            _container.Use(OvertureClientFactory.Create());
            var cartRepository = _container.CreateInstance <CartRepository>();
            var param          = new GetCartsByCustomerIdParam
            {
                Scope              = GetRandom.String(32),
                CultureInfo        = null,
                CustomerId         = GetRandom.Guid(),
                IncludeChildScopes = GetRandom.Boolean()
            };

            // Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => cartRepository.GetCartsByCustomerIdAsync(param));

            //Assert
            exception.ParamName.Should().BeSameAs("param");
            exception.Message.Should().Contain("param.CultureInfo");
        }
        public void WHEN_CultureInfo_Is_Null_SHOULD_Throw_ArgumentException()
        {
            //Arrange
            _container.Use(OvertureClientFactory.Create());
            var cartRepository = _container.CreateInstance <CartRepository>();
            var param          = new GetCartsByCustomerIdParam
            {
                Scope              = GetRandom.String(32),
                CultureInfo        = null,
                CustomerId         = GetRandom.Guid(),
                IncludeChildScopes = GetRandom.Boolean()
            };

            // Act
            Expression <Func <Task <List <CartSummary> > > > expression = () => cartRepository.GetCartsByCustomerIdAsync(param);
            var exception = Assert.ThrowsAsync <ArgumentException>(() => expression.Compile().Invoke());

            //Assert
            exception.ParamName.Should().BeEquivalentTo(GetParamsInfo(expression)[0].Name);
            exception.Message.Should().StartWith(GetMessageOfNull(nameof(param.CultureInfo)));
        }
 public Task <List <CartSummary> > GetCartsByCustomerIdAsync(GetCartsByCustomerIdParam param)
 {
     throw new NotImplementedException();
 }