public void DocumentUpdateProperlyMappedToDocumentUpdateDto() { DocumentUpdateDto upDto1 = new DocumentUpdateDto { Id = 1, DocumentId = 1, IsPublished = true, LatestTopicsUpdated = "This is the first version of the document.", Timestamp = DateTime.Today }; DocumentUpdate up1 = new DocumentUpdate { Id = 1, DocumentId = 1, IsPublished = true, LatestTopicsUpdated = "This is the first version of the document.", Timestamp = DateTime.Today }; DocumentUpdateDto aDto2 = _mapper.Map <DocumentUpdateDto>(up1); Assert.NotNull(aDto2); Assert.True(upDto1.Equals(aDto2)); Assert.True(upDto1.Equals(aDto2, true)); }
public async void GetDocumentUpdatesReturnsListOfUpdates() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new DocumentsInternalController(context, _mapper)) { var result = await controller.GetDocumentUpdates(4); DocumentUpdateDto upTest = _mapper.Map <DocumentUpdateDto>(context.DocumentUpdates.Last(u => u.DocumentId == 4)); Assert.NotNull(result); var okObjectResult = Assert.IsType <OkObjectResult>(result); var resultValue = okObjectResult.Value; Assert.IsAssignableFrom <IEnumerable <DocumentUpdateDto> >(resultValue); Assert.NotEmpty((IEnumerable <DocumentUpdateDto>)resultValue); IEnumerable <DocumentUpdateDto> resultValueList = (IEnumerable <DocumentUpdateDto>)resultValue; Assert.True(resultValueList.Count().Equals(10)); DocumentUpdateDto up = resultValueList.Single(u => u.Id == upTest.Id); Assert.True(upTest.Equals(up)); Assert.True(upTest.Equals(up, true)); } }
public void DocumentUpdateEqualsReturnsCorrectValues() { DocumentUpdateDto up1 = new DocumentUpdateDto { Id = 1, DocumentId = 1, IsPublished = true, LatestTopicsUpdated = "This is the first version of the document.", Timestamp = DateTime.Today }; DocumentUpdateDto up2 = new DocumentUpdateDto { Id = 1, DocumentId = 1, IsPublished = true, LatestTopicsUpdated = "This is the first version of the document.", Timestamp = DateTime.Today }; DocumentUpdateDto up3 = new DocumentUpdateDto { Id = 3, DocumentId = 2, IsPublished = false, LatestTopicsUpdated = "This is the second version of the document.", Timestamp = DateTime.Today.AddDays(1) }; DocumentUpdateDto up4 = new DocumentUpdateDto { Id = 1, DocumentId = 2, IsPublished = false, LatestTopicsUpdated = "This is the second version of the document.", Timestamp = DateTime.Today.AddDays(1) }; Assert.True(up1.Equals(up2)); Assert.True(up1.Equals(up2, true)); Assert.False(up1.Equals(up3)); Assert.False(up1.Equals(up3, true)); Assert.True(up1.Equals(up4)); Assert.False(up1.Equals(up4, true)); }