public async Task <int> ReportComment(ReportedCommentDTO dto) { var report = mapper.Map <ReportedCommentDTO, ReportedComment>(dto); await this.reportedComments.Add(report); return(await this.reportedComments.SaveChangesAsync()); }
public async Task Test_AddCommentReport_ShouldAddCommentReport() { var context = await GetContext(); var service = await GetService(); var reportComment = new ReportedCommentDTO { ReporterId = "a", CreatorId = "b" }; await service.ReportComment(reportComment); Assert.Equal(2, context.ReportedComment.Count()); }
public async Task Test_AddCommentReport_ShouldAddCommentReport() { var context = await this.GetContext(); var commentRepo = new DbRepository <ReportedComment>(context); var offerRepo = new DbRepository <ReportedOffer>(context); var config = new MapperConfiguration(opts => { opts.AddProfile(new ReportProfile()); }); var mapper = config.CreateMapper(); var reportService = new ReportService(commentRepo, offerRepo, mapper); var reportComment = new ReportedCommentDTO { ReporterId = "a", CreatorId = "b" }; await reportService.ReportComment(reportComment); Assert.Equal(2, context.ReportedComment.Count()); }