public void SetUp() { request = new AddReportCommentRequest { ReportId = "id" }; reportComment = new ReportComment(); report = new Report(); reportCommentService = new Mock <IReportCommentService>(); reportValidationHub = new Mock <IReportValidationHub>(); reportManager = new Mock <IReportManager>(); var notifier = new Mock <INotifier>(); var hubManager = new Mock <IHubManager <NotifierHub> >(); mapper = new Mock <IMapper>(); reportCommentService.Setup(rcs => rcs.AddComment(request)).ReturnsAsync(reportComment); reportValidationHub.Setup(rvh => rvh.ValidateAndReturnReport(It.IsNotNull <string>(), It.IsAny <ReportPermission[]>())) .ReturnsAsync(report); reportManager.Setup(rm => rm.ChangeStatus(It.IsAny <ReportStatusType>(), report)).ReturnsAsync(true); addReportCommentCommand = new AddReportCommentCommand(reportCommentService.Object, reportValidationHub.Object, reportManager.Object, notifier.Object, hubManager.Object, mapper.Object); }
public async Task <IActionResult> AddReportComment(AddReportCommentRequest request) { var response = await mediator.Send(request); Log.Information( $"User #{HttpContext.GetCurrentUserId()} added report comment #{response.ReportComment?.Id} to report #{request.ReportId}"); return(this.CreateResponse(response)); }
public void SetUp() { request = new AddReportCommentRequest(); database = new Mock <IDatabase>(); httpContextReader = new Mock <IHttpContextReader>(); database.Setup(d => d.ReportCommentRepository.Insert(It.IsNotNull <ReportComment>(), false)) .ReturnsAsync(true); reportCommentService = new ReportCommentService(database.Object, httpContextReader.Object); }
public async Task <ReportComment> AddComment(AddReportCommentRequest request) { var reportComment = new ReportCommentBuilder() .AddedTo(request.ReportId) .CreatedBy(httpContextReader.CurrentUserId) .SetContent(request.Content) .SetPrivacy(request.IsPrivate) .Build(); return(await database.ReportCommentRepository.Insert(reportComment, false) ? reportComment : throw new DatabaseException()); }