public void TestMoveBookNoSuchShelf() { var shelfManagerMock = new Mock <IShelfManager>(); var bookManagerMock = new Mock <IBookManager>(); bookManagerMock.Setup(m => m.GetListOfBooksByTitle(It.IsAny <string>())) .Returns(new List <Book> { new Book { Title = "Clean Code", ShelfID = 2, } }); shelfManagerMock.Setup(m => m.GetShelf(It.IsAny <int>())) .Returns <Shelf>(null); var bookAPI = new BookAPI(bookManagerMock.Object, shelfManagerMock.Object); var successfull = bookAPI.MoveBookToAnotherShelf("Clean code", 1); Assert.AreEqual(BookErrorCodes.NoSuchShelf, successfull); bookManagerMock.Verify(m => m.MoveBook(It.IsAny <Book>(), It.Is <int>(i => i == 1)), Times.Never); }