Example #1
0
            public async Task PayloadPreenchido_UsuarioEncontrado_RetornaCreated(CreateAuctionInputDto createAuctionInputDto, User user)
            {
                userServiceMock.Setup(mock => mock.GetByIdAsync(It.IsAny <string>())).ReturnsAsync(user);

                HttpResponseMessage response = await httpClient.PostAsJsonAsync(endpointUri, createAuctionInputDto);

                bool wasDeserializationSuccessful = response.Content.TryGetContentValue(out AuctionDto auctionDtoReturned);

                Assert.Equal(HttpStatusCode.Created, response.StatusCode);
                Assert.NotNull(response.Headers.Location);
                Assert.True(wasDeserializationSuccessful);
                Assert.NotNull(auctionDtoReturned);
                userServiceMock.Verify(mock => mock.GetByIdAsync(It.IsAny <string>()), Times.Once);
                auctionServiceMock.Verify(mock => mock.CreateAsync(It.IsAny <Auction>()), Times.Once);
            }
Example #2
0
            public async Task PayloadPreenchido_UsuarioNaoEncontrado_RetornaBadRequest(CreateAuctionInputDto createAuctionInputDto)
            {
                HttpResponseMessage response = await httpClient.PostAsJsonAsync(endpointUri, createAuctionInputDto);

                Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
                userServiceMock.Verify(mock => mock.GetByIdAsync(It.IsAny <string>()), Times.Once);
                auctionServiceMock.Verify(mock => mock.CreateAsync(It.IsAny <Auction>()), Times.Never);
            }