public void GetUserComments(RestAPIGetUserCommentsResponse response, int IdeaId) { List <RESTAPIIdeaCommentInterchange> userCommentInterchangeList = null; List <IdeaComment> commentlist = null; DatabaseWrapper.databaseOperation(response, (context, query) => { userCommentInterchangeList = new List <RESTAPIIdeaCommentInterchange>(); commentlist = new List <IdeaComment>(); commentlist = query.GetIdeaComment(context, IdeaId); if (commentlist.Count > 0) { foreach (var comment in commentlist) { RESTAPIIdeaCommentInterchange commentInterchange = new RESTAPIIdeaCommentInterchange(comment); userCommentInterchangeList.Add(commentInterchange); } } response.Status = Success; } , readOnly: true ); if (userCommentInterchangeList != null && userCommentInterchangeList.Count > 0) { response.UserCommentList.AddRange(userCommentInterchangeList); } }
public RestAPIGetUserCommentsResponse GetIdeaComments([FromUri] int IdeaId) { RestAPIGetUserCommentsResponse response = new RestAPIGetUserCommentsResponse(); submitIdeaUtil.GetUserComments(response, IdeaId); return(response); }
public void GetIdeaCommentsTest() { RESTAPIIdeaController apiController = new RESTAPIIdeaController() { DeviceWithDbContext = new RESTAPIDeviceWithDbContext() { DbContext = new IdeaDatabase.DataContext.IdeaDatabaseDataContext() } }; RestAPIGetUserCommentsResponse response = new RestAPIGetUserCommentsResponse(); int IdeaId = 1; Assert.IsNotNull(apiController.GetIdeaComments(IdeaId)); submitIdeaMock.Verify(x => x.GetUserComments(It.IsAny <RestAPIGetUserCommentsResponse>(), It.IsAny <int>())); }
public void GetIdeaCommentsTest() { RestAPIGetUserCommentsResponse response = new RestAPIGetUserCommentsResponse(); IdeaComment ideaComment = new IdeaComment(); int IdeaId = 1; queryUtilMock.Setup(x => x.GetIdeaComment(It.IsAny <IIdeaDatabaseDataContext>(), It.IsAny <int>())).Returns(new List <IdeaComment>() { new IdeaComment() { IdeaCommentId = 1, CommentDescription = "test", User = new User() { FirstName = "Sanjay" } } }); submitIdeaMock.Setup(x => x.GetUserComments(It.IsAny <RestAPIGetUserCommentsResponse>(), It.IsAny <int>())); submitIdeaUtil.GetUserComments(response, IdeaId); Assert.IsTrue(response.ErrorList.Count == 0); }