Esempio n. 1
0
        public void TestRemoveNonExistingShelf()
        {
            var shelfManagerMock = new Mock <IShelfManager>();
            var bookManagerMock  = new Mock <IBookManager>();

            shelfManagerMock.Setup(m =>
                                   m.GetShelfByShelfNumber(It.IsAny <int>(), It.IsAny <int>()))
            .Returns((Shelf)null);

            var libraryAPI  = new LibraryAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var successfull = libraryAPI.RemoveShelf(106, 6);

            Assert.AreEqual(ShelfStatusCodes.NoSuchShelf, successfull);
            shelfManagerMock.Verify(m =>
                                    m.RemoveShelf(It.IsAny <int>()), Times.Never);
        }
Esempio n. 2
0
        public void TestRemoveEmptyShelf()
        {
            var bookManagerMock  = new Mock <IBookManager>();
            var shelfManagerMock = new Mock <IShelfManager>();

            shelfManagerMock.Setup(m =>
                                   m.GetShelfByShelfNumber(It.IsAny <int>()))
            .Returns(new Shelf
            {
                ShelfNumber = 4,
                Book        = new List <Book>()
            });

            var libraryAPI  = new LibraryAPI(null, shelfManagerMock.Object, bookManagerMock.Object, null);
            var successfull = libraryAPI.RemoveShelf(4);

            Assert.AreEqual(RemoveShelfErrorCodes.Ok, successfull);
            shelfManagerMock.Verify(m =>
                                    m.RemoveShelf(It.IsAny <int>()), Times.Once);
        }
Esempio n. 3
0
        public void TestRemoveShelfWithOneBook()
        {
            var shelfManagerMock = new Mock <IShelfManager>();
            var bookManagerMock  = new Mock <IBookManager>();

            shelfManagerMock.Setup(m =>
                                   m.GetShelfByShelfNumber(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(new Shelf
            {
                ShelfNumber = 101,
                Book        = new List <Book>
                {
                    new Book()
                }
            });

            var libraryAPI  = new LibraryAPI(shelfManagerMock.Object, bookManagerMock.Object);
            var successfull = libraryAPI.RemoveShelf(101, 1);

            Assert.AreEqual(ShelfStatusCodes.ShelfHasBooks, successfull);
            shelfManagerMock.Verify(m =>
                                    m.RemoveShelf(It.IsAny <int>()), Times.Never);
        }