public void CreateDTOFromEntity_NullInput() { //Act var poemDTO = PoemDTO.CreateDTOFromEntity(entity: null); //Assert Assert.NotNull(poemDTO); }
public void IsEmpty_AllPropertiesEmpty_ExpectTrue() { //Arrange var poemDTO = new PoemDTO(); //Act var testResult = poemDTO.IsEmpty(); //Assert Assert.True(testResult); }
public void IsEmpty_MixProperties_ExpectFalse() { //Arrange var poemDTO = new PoemDTO() { Body = "body" }; //Act var testResult = poemDTO.IsEmpty(); //Assert Assert.False(testResult); }
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); }
public void IsEmpty_AllPropertiesNonEmpty_ExpectFalse() { //Arrange var poemDTO = new PoemDTO() { Title = "title", Body = "body" }; //Act var testResult = poemDTO.IsEmpty(); //Assert Assert.False(testResult); }
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); }
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); }