public void TestUpdateBook() { var costumerManagerMock = new Mock <ICostumerManager>(); var bookManagerMock = new Mock <IBookManager>(); var costumerAPI = new CostumerAPI(costumerManagerMock.Object, bookManagerMock.Object); bookManagerMock.Setup(m => m.GetBookByName(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <int>())) .Returns(new Book { BookID = 20, BookName = "Clean Code", InLibrary = false, BookCondition = 5, }); costumerManagerMock.Setup(m => m.ReturnBookToLibrary(It.IsAny <int>(), It.IsAny <bool>())); var successfull = costumerAPI.UpdateBookCondition(0, 0, "Clean Code", true); Assert.IsTrue(successfull); bookManagerMock.Verify( m => m.UpdateBookCondition(0, 0), Times.Once()); }
public void TestUpdateNoneExistingBook() { var costumerManagerMock = new Mock <ICostumerManager>(); var bookManagerMock = new Mock <IBookManager>(); var costumerAPI = new CostumerAPI(costumerManagerMock.Object, bookManagerMock.Object); costumerManagerMock.Setup(m => m.ReturnBookToLibrary(It.IsAny <int>(), It.IsAny <bool>())); var successfull = costumerAPI.UpdateBookCondition(0, 0, "Clean Code", true); Assert.IsFalse(successfull); bookManagerMock.Verify( m => m.UpdateBookCondition(0, 0), Times.Never()); }