public async System.Threading.Tasks.Task testCategoriesGetAsync() { var comments = new List<Comments> { new Comments() { Id = "test1" }, new Comments() { Id = "test2" }, }; var fakeRepositoryMock = new Mock<ICommentsRepository>(); fakeRepositoryMock.Setup(x => x.GetAll()).ReturnsAsync(comments); var commentsService = new CommentsService(fakeRepositoryMock.Object); var resltComments = await commentsService.GetComments(); Xunit.Assert.Collection(resltComments, comments => { Xunit.Assert.Equal("test1", comments.Id); }, comments => { Xunit.Assert.Equal("test2", comments.Id); }); }
public IHttpActionResult GetComments(int userId = 0) { using (CommentsService commentsSvc = new CommentsService()) { IEnumerable <Comment> commentsTask = commentsSvc.GetComments(userId); return(Ok(commentsTask)); } }
public void GetAllShouldReturnCorrectNumberOfPages() { var options = new DbContextOptionsBuilder <ExpensesDbContext>() .UseInMemoryDatabase(databaseName: nameof(GetAllShouldReturnCorrectNumberOfPages)) .Options; using (var context = new ExpensesDbContext(options)) { var commentsService = new CommentsService(context); var expenseService = new ExpenseService(context); var addedExpense = expenseService.Create(new Lab2.DTOs.PostExpenseDto { Description = "fdsfsd", Date = new DateTime(), Comments = new List <Comment>() { new Comment { Important = true, Text = "asd", Owner = null } }, Currency = "large", Sum = 5, Type = "food", Location = "aaa" }, null); var allComments = commentsService.GetComments(1, string.Empty); Assert.AreEqual(1, allComments.NumberOfPages); } }
public async Task <IEnumerable <CommentDto> > Get() { using (var context = new AdaptivContext()) { var repo = new QueryCommentServiceRepository <MetaAdaptivReconComment>(context); var service = new CommentsService(); var comments = await service.GetComments(repo); return(Mapper.Map <IEnumerable <MetaAdaptivReconComment>, IEnumerable <CommentDto> >(comments)); } }
public IActionResult GetComments(int responseId) { try { var comments = _commentsService.GetComments(responseId); return(Ok(comments)); } catch (Exception) { return(NotFound()); } }
public IEnumerable <CommentItemDto> GetComments(int pushId) { var anunt = _anuntService.GetAnuntWithRole(pushId); if (User.IsInRole(anunt.Role)) { var result = _commentsService.GetComments(pushId); return(result); } return(null); }
public async Task <CommentDto> GetById(int id) { using (var context = new AdaptivContext()) { var repo = new QueryCommentServiceRepository <MetaAdaptivReconComment>(context); var service = new CommentsService(); var comments = (await service.GetComments(repo)) .Where(x => x.CommentKey == id) .FirstOrDefault(); return(Mapper.Map <MetaAdaptivReconComment, CommentDto>(comments)); } }
public ActionResult GetComments(int id) { try { ViewData["ResponseId"] = id; var comments = _commentsService.GetComments(id); return(View(comments)); } catch (Exception) { return(NotFound()); } }
// GET: Comments public IActionResult Index() { return(View(_service.GetComments())); }
public ActionResult Index() { List <Comment> model = _commentsService.GetComments(); return(View(model)); }