public void TestReturnNonExistingLoan() { var customerManagerMock = SetupMock(new Customer { CustomerName = "Erika Axelsson" }); var bookManagerMock = SetupMock(new Book { BookTitle = "ABC" }); var loanManagerMock = SetupMock((Loan)null); var loanAPI = new LoanAPI(loanManagerMock.Object, bookManagerMock.Object, customerManagerMock.Object); var successfull = loanAPI.ReturnLoanedBook("ABC", "Erika Axelsson", 4); Assert.AreEqual(LoanedBookStatusCodes.NoSuchLoan, successfull); loanManagerMock.Verify(m => m.ReturnLoanedBook(It.IsAny<int>()), Times.Never); }
public void TestReturnLoanedBook() { var customerManagerMock = SetupMock(new Customer { CustomerName = "Erika Axelsson" }); var bookManagerMock = SetupMock(new Book { BookTitle = "Peter Pan" }); var loanManagerMock = SetupMock(new Loan { LoanID = 1, Book = new Book() }); var loanAPI = new LoanAPI(loanManagerMock.Object, bookManagerMock.Object, customerManagerMock.Object); var successfull = loanAPI.ReturnLoanedBook("Peter Pan", "Erika Axelsson", 2); Assert.AreEqual(LoanedBookStatusCodes.Ok, successfull); loanManagerMock.Verify(m => m.ReturnLoanedBook(It.IsAny<int>()), Times.Once); }