public void ShouldReturnErrorCodes(long cartId, long userId, CartValidationErrors expectedError)
        {
            AddProductToCartValidation      AddProductToCartValidation      = new AddProductToCartValidation();
            CartCreateRequestValidation     CartCreateRequestValidation     = new CartCreateRequestValidation();
            CartFindRequestValidation       CartFindRequestValidation       = new CartFindRequestValidation();
            CartRemoveRequestValidation     CartRemoveRequestValidation     = new CartRemoveRequestValidation();
            RemoveFromCartRequestValidation RemoveFromCartRequestValidation = new RemoveFromCartRequestValidation();
            CartClearRequestValidation      CartClearRequestValidation      = new CartClearRequestValidation();

            CartValidation _validation = new CartValidation(AddProductToCartValidation, CartCreateRequestValidation,
                                                            CartFindRequestValidation, CartRemoveRequestValidation, RemoveFromCartRequestValidation, CartClearRequestValidation);

            var request = new CartCreateRequest
            {
                UserId = userId,
                CartId = cartId
            };

            var listErrors = _validation.CartCreateRequestValidation.Validate(request);

            foreach (var error in listErrors)
            {
                Assert.Equal(expectedError, error);
            }
        }
Esempio n. 2
0
 public CartValidation(AddProductToCartValidation addProductToCartValidation, CartCreateRequestValidation cartCreateRequestValidation,
                       CartFindRequestValidation cartFindRequestValidation, CartRemoveRequestValidation cartRemoveRequestValidation,
                       RemoveFromCartRequestValidation removeFromCartRequestValidation, CartClearRequestValidation cartClearRequestValidation)
 {
     AddProductToCartValidation      = addProductToCartValidation;
     CartCreateRequestValidation     = cartCreateRequestValidation;
     CartFindRequestValidation       = cartFindRequestValidation;
     CartRemoveRequestValidation     = cartRemoveRequestValidation;
     RemoveFromCartRequestValidation = removeFromCartRequestValidation;
     CartClearRequestValidation      = cartClearRequestValidation;
 }