public void extend_date_extends_book_return_date() { //given int randomBookId = rnd.Next(1, TestData.IssuedBooks.Count); var issuedBook = TestData.IssuedBooks.Where(s => s.BookId == randomBookId); moqBookService.Setup(m => m.GetIssuedBooks()).Returns(issuedBook); moqBookAllocationService.Setup(m => m.ExtendReturndate(It.IsAny <IssuedBook>(), It.IsAny <int>())).Returns(true); var sut = new BookStoreService(moqStudentService.Object, moqBookService.Object, moqBookAllocationService.Object); //when var result = sut.ExtendReturnDate(issuedBook.First().BookId, rnd.Next(1, 10)); //then Assert.IsInstanceOfType(result, typeof(bool)); Assert.IsTrue(result); moqBookService.Verify(v => v.GetIssuedBooks(), Times.Once); moqBookAllocationService.Verify(v => v.ExtendReturndate(It.IsAny <IssuedBook>(), It.IsAny <int>()), Times.Once); }