public void CommentMapperToDomainEntitiesTest() { List <GetCommentDto> getCommentDtos = new List <GetCommentDto> { new GetCommentDto { UserId = Guid.NewGuid(), CreatedOn = DateTime.Now, Id = Guid.NewGuid(), Text = "Test1", Handle = "UserName1" }, new GetCommentDto { UserId = Guid.NewGuid(), CreatedOn = DateTime.Now, Id = Guid.NewGuid(), Text = "Test2", Handle = "UserName2" }, }; var comments = _mapper.ToDomainEntities(getCommentDtos); Assert.AreEqual(getCommentDtos[0].Handle, comments[0].CreatedBy); Assert.AreEqual(getCommentDtos[0].CreatedOn, comments[0].CreatedOn); Assert.AreEqual(getCommentDtos[0].Id, comments[0].Id); Assert.AreEqual(getCommentDtos[0].Text, comments[0].Text); Assert.AreEqual(getCommentDtos[1].Handle, comments[1].CreatedBy); Assert.AreEqual(getCommentDtos[1].CreatedOn, comments[1].CreatedOn); Assert.AreEqual(getCommentDtos[1].Id, comments[1].Id); Assert.AreEqual(getCommentDtos[1].Text, comments[1].Text); }
public async override Task InitializeAsync(object navigationData) { try { IsBusy = true; _postId = (Guid)navigationData; var comments = await _commentService.GetPostComments(_postId, _runtimeContext.Token); Comments = new ObservableCollection <Comment>(_commentMapper.ToDomainEntities(comments)); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } finally { IsBusy = false; } }