Beispiel #1
0
        public async Task Post_shouldReturnBadRequest_WhenProductIdIsNotProvided()
        {
            //Arrange
            int    customerId = 1;
            string productId  = "";

            var sut = new WishlistController(_wishlistService);

            //Act
            var result = await sut.PostAsync(customerId, productId);

            //Assert
            Assert.Equal((int)HttpStatusCode.BadRequest, (result.Result as ObjectResult).StatusCode);
        }
Beispiel #2
0
        public async Task Post_shouldReturnNotFound_WhenItIsNotPossibleToAddProduct()
        {
            //Arrange
            int             customerId = 1;
            string          productId  = "1";
            WishListProduct notFound   = null;

            _wishlistService.AddProductToCustomerrWishlistAsync(customerId, productId).Returns(notFound);

            var sut = new WishlistController(_wishlistService);

            //Act
            var result = await sut.PostAsync(customerId, productId);

            //Assert
            Assert.Equal((int)HttpStatusCode.NotFound, (result.Result as StatusCodeResult).StatusCode);
        }
Beispiel #3
0
        public async Task Post_shouldReturnCreated_WhenItIsPossibleToAddProduct()
        {
            //Arrange
            int             customerId      = 1;
            string          productId       = "1";
            WishListProduct existingProduct = new WishListProduct();

            _wishlistService.AddProductToCustomerrWishlistAsync(customerId, productId).Returns(existingProduct);

            var sut = new WishlistController(_wishlistService);

            //Act
            var result = await sut.PostAsync(customerId, productId);

            //Assert
            Assert.Equal((int)HttpStatusCode.Created, (result.Result as ObjectResult).StatusCode);
        }