Esempio n. 1
0
        void GetDefaultPoem_VerifyCorrectSpecificationIsUsed()
        {
            //Arrange
            var mockRepository = new Mock <IEntityRepository <Poem> >();

            mockRepository.Setup(r => r.GetBySpec(It.IsAny <GetDefaultPoemSpec>()));

            //Act
            var service    = new RetrievePoemService(mockRepository.Object);
            var testResult = service.GetDefaultPoem();

            //Assert
            mockRepository.Verify(r => r.GetBySpec(It.IsAny <GetDefaultPoemSpec>()));
        }
Esempio n. 2
0
        void GetDefaultPoem_RepositoryReturnsNull_ExpectEmptyPoemDTO()
        {
            //Arrange
            var mockRepository = new Mock <IEntityRepository <Poem> >();

            mockRepository.Setup(r => r.GetBySpec(It.IsAny <GetDefaultPoemSpec>()))
            .Returns((Poem)null);

            //Act
            var service    = new RetrievePoemService(mockRepository.Object);
            var testResult = service.GetDefaultPoem();

            //Assert
            Assert.NotNull(testResult);
        }
Esempio n. 3
0
        void GetDefaultPoem_RepositoryReturnsValidPoem_ExpectPoemDTOIsSetCorrectly()
        {
            //Arrange
            var poem = new PoemBuilder().Default().Build();

            poem.PublishedRevision = poem.PoemRevisions.FirstOrDefault();
            var mockRepository = new Mock <IEntityRepository <Poem> >();

            mockRepository.Setup(r => r.GetBySpec(It.IsAny <GetDefaultPoemSpec>()))
            .Returns(poem);

            //Act
            var service    = new RetrievePoemService(mockRepository.Object);
            var testResult = service.GetDefaultPoem();

            //Assert
            Assert.Equal(poem.Id, testResult.Id);
            Assert.Equal(poem.PublishedRevision.Title, testResult.Title);
            Assert.Equal(poem.PublishedRevision.Body, testResult.Body);
        }