Ejemplo n.º 1
0
        public async Task <ActionResult <RequestStatusDto> > Bid([FromBody] BidCommandDto commandDto)
        {
            var cmd      = _mapper.MapDto <BidCommandDto, BidCommand>(commandDto);
            var response = await _wsCommandMediator.Send(cmd);

            return(this.StatusResponse(response));
        }
Ejemplo n.º 2
0
        public async Task ApiBidCommand_when_issued_by_creator_fails()
        {
            var           fixture    = new Fixture();
            BidCommandDto commandDto = fixture.Build <BidCommandDto>()
                                       .With(dto => dto.AuctionId, TestUtils.TestAuctionGuid)
                                       .With(dto => dto.Price, 20)
                                       .Create();

            var sem = new SemaphoreSlim(0, 1);

            mockRequestStatusService.Setup(service => service.TrySendRequestFailureToUser(It.IsAny <string>(),
                                                                                          It.IsAny <CorrelationId>(), It.IsAny <UserIdentity>(), null))
            .Callback(() => sem.Release());
            mockRequestStatusService.Verify(service => service.TrySendRequestCompletionToUser(It.IsAny <string>(),
                                                                                              It.IsAny <CorrelationId>(), It.IsAny <UserIdentity>(), null), Times.Never());


            var cmdReq = new HttpRequestMessage(HttpMethod.Post, "/api/bid")
                         .AddUserAuthHeader(_factory)
                         .AddJsonBody(commandDto);

            var response = await client.SendAsync(cmdReq);

            response.StatusCode.Should().Be(HttpStatusCode.OK);
            var requestStatus = await response.GetRequestStatus();

            requestStatus.Status.Should().Be("PENDING");

            if (!sem.Wait(TimeSpan.FromSeconds(10)))
            {
                Assert.Fail();
            }
        }