Пример #1
0
        public async Task <ActionResult <RequestStatusDto> > CreateAuction([FromBody] CreateAuctionCommandDto commandDto)
        {
            var cmd      = _mapper.MapDto <CreateAuctionCommandDto, CreateAuctionCommand>(commandDto);
            var response = await _httpQueuedCommandMediator.Send(cmd);

            return(this.StatusResponse(response));
        }
Пример #2
0
        public async Task ApiCreateAuction_when_session_started_creates_auction()
        {
            var fixture = new Fixture();

            var categoryTreeService = new CategoryTreeService(new CategoryNameServiceSettings()
            {
                CategoriesFilePath = "_Categories-xml-data/categories.xml",
                SchemaFilePath     = "_Categories-xml-data/categories.xsd"
            });

            categoryTreeService.Init();
            List <string> categories = new List <string>()
            {
                categoryTreeService.GetCategoriesTree().SubCategories[0].CategoryName,
                          categoryTreeService.GetCategoriesTree().SubCategories[0].SubCategories[1].CategoryName,
                          categoryTreeService.GetCategoriesTree().SubCategories[0].SubCategories[1].SubCategories[2].CategoryName,
            };


            CreateAuctionCommandDto createAuctionCmd = fixture.Build <CreateAuctionCommandDto>()
                                                       .With(dto => dto.Category, categories)
                                                       .With(dto => dto.StartDate, DateTime.UtcNow)
                                                       .With(dto => dto.EndDate, DateTime.UtcNow.AddMonths(1))
                                                       .With(dto => dto.Tags, new[] { "tag1", "tag2" })
                                                       .Create();

            var startSessionReq = new HttpRequestMessage(HttpMethod.Post, "/api/startCreateSession")
                                  .AddUserAuthHeader(_factory);
            var startSessionResponse = await client.SendAsync(startSessionReq);

            startSessionResponse.StatusCode.Should().Be(HttpStatusCode.OK);

            var req = new HttpRequestMessage(HttpMethod.Post, "/api/createAuction")
                      .AddUserAuthHeader(_factory)
                      .AddJsonBody(createAuctionCmd);
            var response = await client.SendAsync(req);


            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var requestStatus = await response.GetRequestStatus();

            requestStatus.CorrelationId.Should().NotBeEmpty();
            requestStatus.Status.Should().Be("COMPLETED");
        }