Exemple #1
0
        public void CreateDTOFromEntity_NullInput()
        {
            //Act
            var poemDTO = PoemDTO.CreateDTOFromEntity(entity: null);

            //Assert
            Assert.NotNull(poemDTO);
        }
Exemple #2
0
        public void IsEmpty_AllPropertiesEmpty_ExpectTrue()
        {
            //Arrange
            var poemDTO = new PoemDTO();

            //Act
            var testResult = poemDTO.IsEmpty();

            //Assert
            Assert.True(testResult);
        }
Exemple #3
0
        public void IsEmpty_MixProperties_ExpectFalse()
        {
            //Arrange
            var poemDTO = new PoemDTO()
            {
                Body = "body"
            };

            //Act
            var testResult = poemDTO.IsEmpty();

            //Assert
            Assert.False(testResult);
        }
Exemple #4
0
        public void IsEmpty_AllPropertiesNull_ExpectTrue()
        {
            //Arrange
            var poemDTO = new PoemDTO();

            poemDTO.Title = null;
            poemDTO.Body  = null;

            //Act
            var testResult = poemDTO.IsEmpty();

            //Assert
            Assert.True(testResult);
        }
Exemple #5
0
        public void IsEmpty_AllPropertiesNonEmpty_ExpectFalse()
        {
            //Arrange
            var poemDTO = new PoemDTO()
            {
                Title = "title",
                Body  = "body"
            };

            //Act
            var testResult = poemDTO.IsEmpty();

            //Assert
            Assert.False(testResult);
        }
Exemple #6
0
        public static PoemDTO CreateDTOFromEntity(Poem entity)
        {
            var poemDTO = new PoemDTO();

            if (entity != null)
            {
                poemDTO.Id = entity.Id;
                if (entity.PublishedRevision != null)
                {
                    poemDTO.Title = entity.PublishedRevision.Title;
                    poemDTO.Body  = entity.PublishedRevision.Body;
                }
            }
            return(poemDTO);
        }
Exemple #7
0
        public void CreateDTOFromEntity_ValidInput()
        {
            //Arrange
            var poemEntity = new PoemBuilder().Default().Build();

            poemEntity.PublishedRevision = poemEntity.PoemRevisions.FirstOrDefault();

            //Act
            var poemDTO = PoemDTO.CreateDTOFromEntity(poemEntity);

            //Assert
            Assert.NotNull(poemDTO);
            Assert.Equal(poemEntity.Id, poemDTO.Id);
            Assert.Equal(poemEntity.PublishedRevision.Title, poemDTO.Title);
            Assert.Equal(poemEntity.PublishedRevision.Body, poemDTO.Body);
        }