Beispiel #1
0
        public async Task Remove_ExistingIntIdPassed_ReturnsOkResult()
        {
            //Arrange
            Mock <ICartItemService> moqRepo = new Mock <ICartItemService>();        //Mock is type of our Interface

            moqRepo.Setup(repo => repo.DeleteCartItem(1));                          //access the function inside the service class and specify what it returns
            CartItemController controller = new CartItemController(moqRepo.Object); //pass context and moq object inside controller

            //Act
            ActionResult okResponse = await controller.Remove_A_CartItem_From_The_Cart(1);

            //Assert
            Assert.IsType <OkResult>(okResponse);
        }
Beispiel #2
0
        public async Task Remove_NullPassed_ReturnsNotFoundResponse()
        {
            //Arrange
            Mock <ICartItemService> moqRepo = new Mock <ICartItemService>();        //Mock is type of our Interface

            moqRepo.Setup(repo => repo.DeleteCartItem(null));                       //access the function inside the service class and specify what it returns
            CartItemController controller = new CartItemController(moqRepo.Object); //pass moq object inside controller

            //Act
            ActionResult badResponse = await controller.Remove_A_CartItem_From_The_Cart(null);

            //Assert
            Assert.IsType <NotFoundResult>(badResponse);
        }