public void ListPoemsByConceivedDate_VerifyCorrectSpecificationIsUsed() { //Arrange var mockPoemRepository = new Mock <IEntityRepository <Poem> >(); mockPoemRepository.Setup(pr => pr.List(It.IsAny <ListPoemsByConceivedDateSpec>())); //Act var service = new ListPoemsService(mockPoemRepository.Object); var testResult = service.ListByConceivedDate(); //Assert mockPoemRepository.Verify(pr => pr.List(It.IsAny <ListPoemsByConceivedDateSpec>())); }
public void ListPoemsByName_RepositoryReturnsEmptyList_ExpectEmptyDTOList() { //Arrange var mockPoemRepository = new Mock <IEntityRepository <Poem> >(); mockPoemRepository.Setup(pr => pr.List(It.IsAny <ListPoemsByNameSpec>())) .Returns(new List <Poem>()); //Act var service = new ListPoemsService(mockPoemRepository.Object); var testResult = service.ListByName(); //Assert Assert.NotNull(testResult); Assert.Empty(testResult); }
public void ListPoemsByLastModifiedDate_RepositoryReturnsNull_ExpectEmptyDTOList() { //Arrange var mockPoemRepository = new Mock <IEntityRepository <Poem> >(); mockPoemRepository.Setup(pr => pr.List(It.IsAny <ListPoemsByLastModifiedDateSpec>())) .Returns((IEnumerable <Poem>)null); //Act var service = new ListPoemsService(mockPoemRepository.Object); var testResult = service.ListByLastModifiedDate(); //Assert Assert.NotNull(testResult); Assert.Empty(testResult); }
public void ListPoemsByName_RepositoryReturnsNonEmptyList_ExpectNonEmptyDTOList() { //Arrange var size = 3; var mockPoemRepository = new Mock <IEntityRepository <Poem> >(); mockPoemRepository.Setup(pr => pr.List(It.IsAny <ListPoemsByNameSpec>())) .Returns(new PoemBuilder().Default().BuildCollection(size)); //Act var service = new ListPoemsService(mockPoemRepository.Object); var testResult = service.ListByName(); //Assert Assert.NotNull(testResult); Assert.Equal(size, testResult.Count()); }