/// <summary>
        /// Gets all payments hold by a cart.
        /// </summary>
        /// <param name="param">Parameters used to make the query.</param>
        /// <returns>A list of Payments.</returns>
        public virtual Task <List <Payment> > GetCartPaymentsAsync(GetCartPaymentsParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), 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));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }

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

            return(OvertureClient.SendAsync(request));
        }
        public void WHEN_customerId_is_empty_SHOULD_throw_ArgumentException()
        {
            //Arrange
            var param = new GetCartPaymentsParam
            {
                CartName    = GetRandom.String(7),
                CustomerId  = Guid.Empty,
                CultureInfo = CultureInfo.InvariantCulture,
                Scope       = GetRandom.String(12)
            };
            //Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => _sut.GetCartPaymentsAsync(param));

            //Assert
            exception.Should().NotBeNull();
            exception.ParamName.Should().Be("param");
            exception.Message.Should().ContainEquivalentOf("CustomerId");
        }
        public void WHEN_scope_is_null_or_whitespace_SHOULD_throw_ArgumentException(string scope)
        {
            //Arrange
            var param = new GetCartPaymentsParam
            {
                CartName    = GetRandom.String(7),
                CustomerId  = GetRandom.Guid(),
                CultureInfo = CultureInfo.InvariantCulture,
                Scope       = scope
            };

            //Act
            Expression <Func <Task <List <Payment> > > > expression = () => _sut.GetCartPaymentsAsync(param);
            var exception = Assert.ThrowsAsync <ArgumentException>(() => expression.Compile().Invoke());

            //Assert
            exception.ParamName.Should().BeEquivalentTo(GetParamsInfo(expression)[0].Name);
            exception.Message.Should().StartWith(GetMessageOfNullWhiteSpace(nameof(param.Scope)));
        }
예제 #4
0
        public void WHEN_scope_is_null_or_whitespace_SHOULD_throw_ArgumentException(string scope)
        {
            //Arrange
            var param = new GetCartPaymentsParam
            {
                CartName    = GetRandom.String(7),
                CustomerId  = GetRandom.Guid(),
                CultureInfo = CultureInfo.InvariantCulture,
                Scope       = scope
            };

            //Act
            var exception = Assert.ThrowsAsync <ArgumentException>(() => _sut.GetCartPaymentsAsync(param));

            //Assert
            exception.Should().NotBeNull();
            exception.ParamName.Should().Be("param");
            exception.Message.Should().ContainEquivalentOf("scope");
        }