コード例 #1
0
        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);
            });
        }
コード例 #2
0
 public IHttpActionResult GetComments(int userId = 0)
 {
     using (CommentsService commentsSvc = new CommentsService()) {
         IEnumerable <Comment> commentsTask = commentsSvc.GetComments(userId);
         return(Ok(commentsTask));
     }
 }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
 public IActionResult GetComments(int responseId)
 {
     try
     {
         var comments = _commentsService.GetComments(responseId);
         return(Ok(comments));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 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));
     }
 }
コード例 #8
0
 public ActionResult GetComments(int id)
 {
     try
     {
         ViewData["ResponseId"] = id;
         var comments = _commentsService.GetComments(id);
         return(View(comments));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
コード例 #9
0
 // GET: Comments
 public IActionResult Index()
 {
     return(View(_service.GetComments()));
 }
コード例 #10
0
        public ActionResult Index()
        {
            List <Comment> model = _commentsService.GetComments();

            return(View(model));
        }