示例#1
0
        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>()));
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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());
        }