public void TestMoveBookOk()
        {
            var shelfManagerMock = new Mock <IShelfManager>();
            var bookManagerMock  = new Mock <IBookManager>();

            shelfManagerMock.Setup(m =>
                                   m.GetShelfByShelfNumber(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(new Shelf {
                ShelfID = 2
            });

            bookManagerMock.Setup(m =>
                                  m.GetBookByBookTitle(It.IsAny <string>()))
            .Returns(new Book
            {
                BookID = 2,
                Shelf  = new Shelf()
            });

            var bookAPI = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var result  = bookAPI.MoveBook("Moby Dick", 101, 2);

            Assert.AreEqual(BookStatusCodes.Ok, result);
            bookManagerMock.Verify(m =>
                                   m.MoveBook(2, 2), Times.Once());
        }
        public void MoveBookOk()
        {
            var shelfManagerMock = new Mock <IShelfManager>();
            var bookManagerMock  = new Mock <IBookManager>();

            shelfManagerMock.Setup(m =>
                                   m.GetShelfByShelfNumber(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(new Shelf {
                ShelfID = 2
            });

            bookManagerMock.Setup(m =>
                                  m.GetBookByBookNumber(It.IsAny <int>()))
            .Returns(new Book
            {
                BookID = 2,
                Shelf  = new Shelf()
            });

            var bookAPI = new BookAPI(bookManagerMock.Object, shelfManagerMock.Object, null);
            var result  = bookAPI.MoveBook(1, 1, 1);

            Assert.AreEqual(ErrorCodesMoveBook.Ok, result);
            bookManagerMock.Verify(m =>
                                   m.MoveBook(2, 2), Times.Once());
        }
Example #3
0
        public void MoveBook()
        {
            var bookManagerMock = new Mock <IBookManager>();

            var shelfManagerMock = new Mock <IShelfManager>();


            shelfManagerMock.Setup(m =>
                                   m.GetShelfByNumber(It.IsAny <int>()))
            .Returns(new Shelf {
                ShelfNr = 2
            });



            bookManagerMock.Setup(m =>
                                  m.GetBookByNumber(It.IsAny <long>()))
            .Returns(new Book
            {
                Shelf   = new Shelf(),
                ShelfNr = 3
            });


            var bookAPI = new BookAPI(bookManagerMock.Object, shelfManagerMock.Object);
            var result  = bookAPI.MoveBook(9780132911221, true);

            Assert.AreEqual(MoveBookErrorCodes.OK, result);
            bookManagerMock.Verify(m =>
                                   m.MoveBook(2, 2), Times.Once());
        }
Example #4
0
        public void MoveBookAlreadyInThatShelf()
        {
            var currentAisle = new Aisle {
                AisleNumber = 1
            };
            var currentShelf = (new Shelf
            {
                ShelfNumber = 1,
                Aisle = currentAisle
            });

            var shelfManagerMock = SetupMock(currentShelf);

            var bookManagerMock = SetupMock(new Book
            {
                BookID = 1,
                Shelf  = currentShelf
            });

            var bookAPI = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var result  = bookAPI.MoveBook("Circe", 1, 1);

            Assert.AreEqual(MoveBookStatusCodes.BookAlreadyInThatShelf, result);
            bookManagerMock.Verify(m =>
                                   m.MoveBook(1, 1), Times.Never());
        }
Example #5
0
        public void MoveBookNoSuchBook()
        {
            var shelfManagerMock = SetupMock(new Shelf {
                ShelfID = 2
            });
            var bookManagerMock = SetupMock((Book)null);

            var bookAPI = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var result  = bookAPI.MoveBook("Circe", 1, 1);

            Assert.AreEqual(MoveBookStatusCodes.NoSuchBook, result);
            shelfManagerMock.Verify(m =>
                                    m.MoveShelf(2, 2), Times.Never());
        }
        public void TestMoveBookNoSuchBook()
        {
            var shelfManagerMock = SetupMock(new Shelf {
                ShelfNumber = 101
            });
            var bookManagerMock = SetupMock((Book)null);

            var bookApi = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var result  = bookApi.MoveBook("ABC", 101, 3);

            Assert.AreEqual(BookStatusCodes.NoSuchBook, result);
            bookManagerMock.Verify(
                m => m.MoveBook(It.Is <int>(i => i == 9), It.Is <int>(i => i == 3)),
                Times.Never());
        }
        public void TestMoveBookNoSuchShelf()
        {
            var shelfManagerMock = SetupMock((Shelf)null);
            var bookManagerMock  = SetupMock(new Book
            {
                BookID    = 4,
                BookTitle = "Moby Dick"
            });

            var bookApi = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var result  = bookApi.MoveBook("Moby Dick", 101, 3);

            Assert.AreEqual(BookStatusCodes.NoSuchShelf, result);
            bookManagerMock.Verify(
                m => m.MoveBook(It.Is <int>(i => i == 4), It.Is <int>(i => i == 12)),
                Times.Never());
        }
Example #8
0
        public void MoveBookOk()
        {
            var shelfManagerMock = SetupMock(new Shelf {
                ShelfID = 2
            });
            var bookManagerMock = SetupMock(new Book
            {
                BookID = 2,
                Shelf  = new Shelf()
            });

            var bookAPI = new BookAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var result  = bookAPI.MoveBook("Circe", 1, 1);

            Assert.AreEqual(MoveBookStatusCodes.Ok, result);
            bookManagerMock.Verify(m =>
                                   m.MoveBook(2, 2), Times.Once());
        }