public void FindShould_ReturnCorrectValue() { // Arrange int bookCatNum = 1; Guid bookId = Guid.NewGuid(); Book book = new Book() { Id = bookId, CatalogueNumber = bookCatNum }; int pageNum1 = 1; int pageNum2 = 2; Page page1 = new Page() { Book = book, Number = pageNum1 }; Page page2 = new Page() { Book = book, Number = pageNum2 }; var list = new List <Page>() { page1, page2 }; var pagesService = new PagesService(pageRepoMock.Object, bookServiceMock.Object, contextMock.Object); // Act bookServiceMock.Setup(x => x.FindSingle(bookCatNum)).Returns(book); pageRepoMock.Setup(x => x.All).Returns(list.AsQueryable); var result = pagesService.Find(bookCatNum, pageNum2); // Assert Assert.AreEqual(page2, result); }
public void FindShould_ReturnCorrectType() { // Arrang var list = new List <Page>(); var pagesService = new PagesService(pageRepoMock.Object, bookServiceMock.Object, contextMock.Object); // Act pageRepoMock.Setup(x => x.All).Returns(list.AsQueryable); var result = pagesService.Find(1, 1); // Assert Assert.IsInstanceOf(typeof(Page), result); }