Exemple #1
0
        public void SetUp()
        {
            createOtherReportRequest = new CreateOtherReportRequest();
            createUserReportRequest  = new CreateUserReportRequest
            {
                UserToReportId = 1
            };
            createPenaltyReportRequest = new CreatePenaltyReportRequest();
            createBugReportRequest     = new CreateBugReportRequest();

            creator = new User();

            database           = new Mock <IDatabase>();
            reportImageService = new Mock <IReportImageService>();
            httpContextReader  = new Mock <IHttpContextReader>();

            database.Setup(d => d.UserRepository.FindById(It.IsAny <int>())).ReturnsAsync(creator);
            database.Setup(d => d.ReportRepository.Insert(It.IsAny <Report>(), false))
            .ReturnsAsync(true);
            database.Setup(d => d.BugReportRepository.Insert(It.IsAny <BugReport>(), false))
            .ReturnsAsync(true);
            database.Setup(d => d.PenaltyReportRepository.Insert(It.IsAny <PenaltyReport>(), false))
            .ReturnsAsync(true);
            database.Setup(d => d.UserReportRepository.Insert(It.IsAny <UserReport>(), false))
            .ReturnsAsync(true);
            database.Setup(d => d.BeginTransaction()).Returns(new DatabaseTransaction());

            reportService = new ReportService(database.Object, reportImageService.Object, httpContextReader.Object);
        }
Exemple #2
0
        public async Task <IActionResult> CreateOtherReport([FromForm] CreateOtherReportRequest request)
        {
            var response = await mediator.Send(request);

            Log.Information($"User #{HttpContext.GetCurrentUserId()} created other report");

            return(this.CreateResponse(response));
        }
Exemple #3
0
        public async Task <Report> CreateOtherReport(CreateOtherReportRequest request)
        {
            var baseReport = await CreateBaseReport(request.Subject, request.Content, request.IsPrivate,
                                                    request.EventDate, request.Type);

            if (!await database.ReportRepository.Insert(baseReport, false))
            {
                throw new DatabaseException();
            }

            await reportImageService.UploadReportImages(httpContextReader.CurrentUserId,
                                                        baseReport,
                                                        request.Images);

            return(baseReport);
        }
        public void SetUp()
        {
            report  = new Report();
            request = new CreateOtherReportRequest();

            var mapper = new Mock <IMapper>();

            reportService = new Mock <IReportService>();
            reportManager = new Mock <IReportManager>();

            reportService.Setup(rs => rs.CreateOtherReport(It.IsAny <CreateOtherReportRequest>()))
            .ReturnsAsync(report);
            mapper.Setup(m => m.Map <ReportDto>(It.IsAny <Report>())).Returns(new ReportDto());

            createOtherReportCommand =
                new CreateOtherReportCommand(reportService.Object, reportManager.Object, mapper.Object);
        }