public void TestRemoveNonexistingShelf() { var shelfManagerMock = new Mock <IShelfManager>(); shelfManagerMock.Setup(m => m.GetShelfByShelfNumber(It.IsAny <int>(), It.IsAny <int>())) .Returns((Shelf)null); var pathAndShelfAPI = new PathAndShelfAPI(null, shelfManagerMock.Object, null); var successfull = pathAndShelfAPI.RemoveShelf(1, 1, 1); Assert.AreEqual(RemoveShelfErrorCodes.NoSuchShelf, successfull); shelfManagerMock.Verify(m => m.RemoveShelf(It.IsAny <int>()), Times.Never); }
public void TestRemoveExistingShelf() { var shelfManagerMock = new Mock <IShelfManager>(); var bookManagerMock = new Mock <IBookManager>(); var pathManagerMock = new Mock <IPathManager>(); shelfManagerMock.Setup(m => m.GetShelfByShelfNumber(It.IsAny <int>(), It.IsAny <int>())) .Returns(new Shelf { ShelfNumber = 4, Books = new List <Book>() }); var PathAndShelfAPI = new PathAndShelfAPI(pathManagerMock.Object, shelfManagerMock.Object, null); var successfull = PathAndShelfAPI.RemoveShelf(1, 4, 1); Assert.AreEqual(RemoveShelfErrorCodes.Ok, successfull); shelfManagerMock.Verify(m => m.RemoveShelf(It.IsAny <int>()), Times.Once); }
public void TestRemoveShelfwithBook() { 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 = 3, Books = new List <Book> { new Book() } }); var pathAndShelfAPI = new PathAndShelfAPI(null, shelfManagerMock.Object, bookManagerMock.Object); var successfull = pathAndShelfAPI.RemoveShelf(3, 3, 1); Assert.AreEqual(RemoveShelfErrorCodes.ShelfHasBooks, successfull); shelfManagerMock.Verify(m => m.RemoveShelf(It.IsAny <int>()), Times.Never); }