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); }
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); }
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); }