public void Deveria_cadastrar_reserva_com_um_cliente() { var flight = FlightBuilder.Start().WithVacancies(40).Build(); var customer = CustomerBuilder.Start().Build(); var flightReservation = FlightReservationBuilder.Start().WithFlight(flight).WithCustomer(customer).Build(); var result = flightReservation.CanRegister(); result.Should().Be("Cadastro validado"); }
public void Nao_deveria_cadastrar_reserva_quando_lotado() { var flight = FlightBuilder.Start().Build(); var customer = CustomerBuilder.Start().Build(); var flightReservation = FlightReservationBuilder.Start().WithFlight(flight).WithCustomer(customer).Build(); var result = flightReservation.CanRegister(); result.Should().Be("Voo lotado"); }
public void Nao_deveria_cadastrar_reserva_com_cliente_ja_cadastrado(int value1, int value2) { var customerRegistered = CustomerBuilder.Start().WithName("Dienisson").Build(); var flightReservationRegistered = FlightReservationBuilder.Start().WithCustomer(customerRegistered).Build(); var flight = FlightBuilder.Start().WithFlighReservation(flightReservationRegistered).WithVacancies(40).Build(); var customer = CustomerBuilder.Start().WithId(value1).WithName("Dienisson").Build(); var customeTwo = CustomerBuilder.Start().WithId(value2).Build(); var flightReservationTwo = FlightReservationBuilder.Start() .WithCustomer(customer) .WithCustomer(customeTwo) .WithFlight(flight) .Build(); var result = flightReservationTwo.CanRegister(); result.Should().Be("Vaga já cadastrado: Dienisson"); }
public static void PopulateTestData(eFlightDbContext dbContext) { var flight = FlightBuilder.Start().WithVacancies(40).Build(); var hotel = HotelBuilder.Start().Build(); var car = CarBuilder.Start().Build(); var travelPackage = TravelPackageBuilder.Start().Build(); dbContext.Flight.Add(flight); dbContext.Hotel.Add(hotel); dbContext.Car.Add(car); dbContext.TravelPackage.Add(travelPackage); dbContext.FlightReservation.Add(FlightReservationBuilder.Start().WithFlight(flight).Build()); dbContext.HotelReservation.Add(HotelReservationBuilder.Start().WithHotel(hotel).Build()); dbContext.CarReservation.Add(CarReservationBuilder.Start().WithCar(car).Build()); dbContext.TravelPackageReservation.Add(TravelPackageReservationBuilder.Start().WithTravelPackage(travelPackage).Build()); dbContext.SaveChanges(); }
public async Task Deveria_atualizar_reserva_de_voo_com_sucesso() { int expected = 1; List <FlightReservation> reservations = new List <FlightReservation>() { FlightReservationBuilder.Start().WithId(1).Build(), FlightReservationBuilder.Start().WithId(2).Build() }; _fakeRepository.Setup(x => x.GetAllIncludeCustomers()).ReturnsAsync(reservations); var cmd = FlightReservationUpdateCommandBuilder.Start().Build(); var result = await _handler.Handle(cmd, It.IsAny <CancellationToken>()); result.Should().BeTrue(); _fakeRepository.Verify(x => x.GetAllIncludeCustomers(), Times.Once); _fakeRepository.Verify(x => x.Update(It.IsAny <FlightReservation>()), Times.Once); }
public void Deveria_adicioanar_um_voo_no_contexto() { //Arrange FlightReservation flightReservation = FlightReservationBuilder.Start().Build(); flightReservation.SetId(); foreach (var customer in flightReservation.FlightReservationCustomers) { customer.SetId(); } //Action var flightReservationAdd = _repository.Add(flightReservation); //Assert var expectedFlight = Context.FlightReservation.Find(flightReservationAdd.Result.Id); expectedFlight.Should().NotBeNull(); }
private void CreateFlighReservation() { FlightReservationSeedOne = FlightReservationBuilder.Start().WithCustomer(CustomerBuilder.Start().Build()).Build(); //FlightReservationSeedOne.SetId(); //foreach (var customer in FlightReservationSeedOne.FlightCustomers) //{ // customer.SetId(); //} FlightReservationSeedTwo = FlightReservationBuilder.Start().WithCustomer(CustomerBuilder.Start().Build()).Build(); //FlightReservationSeedTwo.SetId(); //foreach (var customer in FlightReservationSeedTwo.FlightCustomers) //{ // customer.SetId(); //} FlightReservationSeedOne = _context.FlightReservation.Add(FlightReservationSeedOne).Entity; FlightReservationSeedTwo = _context.FlightReservation.Add(FlightReservationSeedTwo).Entity; }
public async Task Deveria_excluir_reserva_de_voo_com_sucesso() { int expected = 1; FlightReservation reservation = FlightReservationBuilder.Start() .WithInputDate(DateTime.Now.AddDays(11)) .Build(); _fakeRepository.Setup(x => x.GetById(It.IsAny <int>())).ReturnsAsync(reservation); var cmd = new FlightReservationDeleteCommand() { FlightReservationId = 1 }; var result = await _handler.Handle(cmd, It.IsAny <CancellationToken>()); result.Should().BeTrue(); _fakeRepository.Verify(x => x.GetById(cmd.FlightReservationId), Times.Once); _fakeRepository.Verify(x => x.DeleteById(cmd.FlightReservationId), Times.Once); }
public async Task Deveria_recuperar_reserva_de_voo_com_sucesso() { int expected = 1; List <FlightReservation> reservations = new List <FlightReservation>() { FlightReservationBuilder.Start().Build(), FlightReservationBuilder.Start().Build() }; _fakeRepository.Setup(x => x.GetAll()).ReturnsAsync(reservations); var cmd = new FlightReservationLoadAllQuery(); var result = await _handler.Handle(cmd, It.IsAny <CancellationToken>()); result.Should().BeOfType <List <FlightReservation> >(); result.Should().HaveCount(2); _fakeRepository.Verify(x => x.GetAll(), Times.Once); //TODO: Verificar registro atualizado. }
public async Task Deveria_criar_reserva_de_voo_com_sucesso() { var flight = FlightBuilder.Start().WithVacancies(40).Build(); flight.Id = 1; List <FlightReservation> reservations = new List <FlightReservation>() { FlightReservationBuilder.Start().WithFlightId(1).WithFlight(flight).Build(), FlightReservationBuilder.Start().WithFlightId(1).Build() }; _fakeRepository.Setup(x => x.GetAllIncludeCustomers()).ReturnsAsync(reservations); _fakeRepository.Setup(x => x.GetAllIncludeFlight()).ReturnsAsync(reservations); var cmd = FlightReservationRegisterCommandBuilder.Start().Build(); var result = await _handler.Handle(cmd, It.IsAny <CancellationToken>()); result.Should().BeTrue(); _fakeRepository.Verify(x => x.Add(It.IsAny <FlightReservation>()), Times.Once); }
public void DeleteFlightReservation_IntegrationTest() { //arrange var flightReservation = FlightReservationBuilder.Start().WithInputDate(DateTime.Now.AddDays(11)) .WithOutputDate(DateTime.Now.AddDays(20)).Build(); CustomWebApplicationFactory <Startup> .appDb.FlightReservation.Add(flightReservation); CustomWebApplicationFactory <Startup> .appDb.SaveChanges(); var flightCmd = new FlightReservationDeleteCommand() { FlightReservationId = flightReservation.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.FlightReservation.Count().Should().Be(1); }
public void Deveria_excluir_reserva_de_voo_com_mais_de_10_dias() { var flightReservation = FlightReservationBuilder.Start().WithInputDate(DateTime.Now.AddDays(12)).Build(); flightReservation.CanDelete().Should().BeTrue(); }