public async Task <int> ReportOffer(ReportedOfferDTO dto) { var offer = mapper.Map <ReportedOfferDTO, ReportedOffer>(dto); await this.reportedOffers.Add(offer); return(await this.reportedOffers.SaveChangesAsync()); }
public async Task Test_AddOfferReport_ShouldAddCommentReport() { var context = await GetContext(); var service = await GetService(); var reportedOffer = new ReportedOfferDTO { ReporterId = "a", ResourceCreatorId = "b" }; await service.ReportOffer(reportedOffer); Assert.Equal(2, context.ReportedOffers.Count()); }
public async Task Test_AddOfferReport_ShouldAddCommentReport() { var context = await 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 reportedOffer = new ReportedOfferDTO { ReporterId = "a", ResourceCreatorId = "b" }; await reportService.ReportOffer(reportedOffer); Assert.Equal(2, context.ReportedOffers.Count()); }