コード例 #1
0
        public async Task <IActionResult> Delete([FromBody] CarReservationDeleteCommand CarDeleteCmd)
        {
            var result = await _mediator.Send(CarDeleteCmd);

            if (result)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #2
0
        public async void Test_FlightController_DeleteAsync_ShouldBeOk()
        {
            var deleteCommand = new CarReservationDeleteCommand()
            {
                CarReservationId = 1
            };

            _fakeMediator.Setup(mdtr => mdtr.Send(deleteCommand, It.IsAny <CancellationToken>()))
            .ReturnsAsync(true);

            var callback = await _controller.Delete(deleteCommand);


            var response = callback.Should().BeOfType <OkResult>().Subject;
        }
コード例 #3
0
        public void Deveria_excluir_reserva_de_carro_com_sucesso()
        {
            int expected = 1;

            CarReservation reservation = CarReservationBuilder.Start()
                                         .WithInputDate(DateTime.Now.AddDays(11))
                                         .Build();

            _fakeRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(reservation);

            var cmd = new CarReservationDeleteCommand()
            {
                CarReservationId = 1
            };

            var result = _handler.Handle(cmd, It.IsAny <CancellationToken>());

            result.Result.Should().BeTrue();
            _fakeRepository.Verify(x => x.GetById(cmd.CarReservationId), Times.Once);
            _fakeRepository.Verify(x => x.DeleteById(cmd.CarReservationId), Times.Once);
        }
コード例 #4
0
        public void DeleteCarReservation_IntegrationTest()
        {
            //arrange
            var carReservation = CarReservationBuilder.Start().WithInputDate(DateTime.Now.AddDays(11))
                                 .WithOutputDate(DateTime.Now.AddDays(20)).Build();

            CustomWebApplicationFactory <Startup> .appDb.CarReservation.Add(carReservation);

            CustomWebApplicationFactory <Startup> .appDb.SaveChanges();

            var flightCmd = new CarReservationDeleteCommand()
            {
                CarReservationId = carReservation.Id
            };
            var myContent     = JsonConvert.SerializeObject(flightCmd);
            var stringContent = new StringContent(myContent, UnicodeEncoding.UTF8, "application/json");

            //action
            var httpResponse = eFlight.Tests.Common.Extensions.HttpClientExtensions.DeleteAsync(_client, _url, stringContent).Result;

            httpResponse.EnsureSuccessStatusCode();

            CustomWebApplicationFactory <Startup> .appDb.CarReservation.Count().Should().Be(1);
        }