public void InvokesGetUserOnce_When_AddBookToShoppingCartIsCalledWithCorrectParams()
        {
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var mapperStub     = new Mock <IMapper>();
            var fakeUser       = new BookstoreUser()
            {
                Id = 1
            };
            var fakeBook         = new Book();
            var fakeShoppingCart = new ShoppingCart()
            {
                UserId = 1
            };
            var fakeShoppingCarts = new List <ShoppingCart>()
            {
                fakeShoppingCart
            }.AsQueryable();
            var shoppingCartService = new ShoppingCartService(unitOfWorkMock.Object, mapperStub.Object);

            unitOfWorkMock.Setup(x => x.ShoppingCartStatuses.GetById(It.IsAny <int>()));
            unitOfWorkMock.Setup(x => x.Users.GetById(1)).Returns(fakeUser).Verifiable();
            unitOfWorkMock.Setup(x => x.Books.GetById(1)).Returns(fakeBook);
            unitOfWorkMock.Setup(x => x.ShoppingCarts.All()).Returns(fakeShoppingCarts);

            shoppingCartService.AddBookToShoppingCart(1, 1);

            unitOfWorkMock.Verify(x => x.Users.GetById(1), Times.Once);
        }
        public void ThrowArgumentException_When_AddBookToShoppingCartIsCalledWithNonExistentBookId()
        {
            var unitOfWorkMock = new Mock <IUnitOfWork>();
            var mapperStub     = new Mock <IMapper>();

            var shoppingCartService = new ShoppingCartService(unitOfWorkMock.Object, mapperStub.Object);

            var validBookId   = -1;
            var invalidUserId = 2;

            Assert.ThrowsException <ArgumentException>(() => shoppingCartService.AddBookToShoppingCart(validBookId, invalidUserId));
        }