private static AddBookErrorCodes AddBookNumberOne(Mock <IBookManager> bookManagerMock) { var libraryAPI = new LibraryAPI(null, null, bookManagerMock.Object, null); var successfull = libraryAPI.AddBook(1, "Astrophysics for People in a Hurry", " Neil Degrasse Tyson", "9780393609394", 2); return(successfull); }
public void TestAddBookBookNotGivenAnAuthor() { var bookManagerMock = new Mock <IBookManager>(); var libraryAPI = new LibraryAPI(null, null, bookManagerMock.Object, null); var successfull = libraryAPI.AddBook(1, "Astrophysics for People in a Hurry", null, "9780393609394", 2); Assert.AreEqual(AddBookErrorCodes.BookNotGivenAnAuthor, successfull); bookManagerMock.Verify(m => m.AddBook(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()), Times.Never()); }
public void TestAddBookBookNotGivenATitle() { var bookManagerMock = new Mock <IBookManager>(); var libraryAPI = new LibraryAPI(null, null, bookManagerMock.Object, null); var successfull = libraryAPI.AddBook(1, null, " Neil Degrasse Tyson", "9780393609394", 2); Assert.AreEqual(AddBookErrorCodes.BookNotGivenATitle, successfull); bookManagerMock.Verify(m => m.AddBook(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()), Times.Never()); }
public void TestAddBookISBNNumberNotValid() { var bookManagerMock = new Mock <IBookManager>(); var libraryAPI = new LibraryAPI(null, null, bookManagerMock.Object, null); var successfull = libraryAPI.AddBook(1, "Astrophysics for People in a Hurry", " Neil Degrasse Tyson", "9780393609395", 2); Assert.AreEqual(AddBookErrorCodes.ISBNNumberNotValid, successfull); bookManagerMock.Verify(m => m.AddBook(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>()), Times.Never()); }
public void TestAddExistingBook() { var SectionManagerMock = new Mock <ISectionManager>(); var shelfManagerMock = new Mock <IShelfManager>(); var BookManagerMock = new Mock <IBookManager>(); BookManagerMock.Setup(m => m.GetBookByName(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <int>())) .Returns(new Book()); BookManagerMock.Setup(m => m.AddBook(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <long>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>())); var libraryAPI = new LibraryAPI(SectionManagerMock.Object, shelfManagerMock.Object, BookManagerMock.Object); var successfull = libraryAPI.AddBook("Clean Code", 199, 9780132350884, true, true, 5); Assert.IsFalse(successfull); BookManagerMock.Verify( m => m.AddBook(It.Is <string>(i => i == "Clean Code"), It.Is <int>(i => i == 199), It.Is <long>(i => i == 9780132350884), It.Is <bool>(i => i == true), It.Is <bool>(i => i == true), It.Is <int>(i => i == 5)), Times.Never()); }