Ejemplo n.º 1
0
        public async Task CreateShouldReturn201Created()
        {
            var basketServiceMock = new Mock <IBasketService>(MockBehavior.Strict);

            basketServiceMock.Setup(service => service.CreateBasket()).ReturnsAsync(new Basket());

            var productServiceMock = new Mock <IProductService>(MockBehavior.Strict);

            var controller = new BasketsController(basketServiceMock.Object, productServiceMock.Object);

            var result = await controller.Create();

            Assert.IsType <CreatedAtRouteResult>(result);

            basketServiceMock.Verify(service => service.CreateBasket(), Times.Once);
            basketServiceMock.VerifyAll();
        }