Exemplo n.º 1
0
        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 void Test_Flight_Controller_GetAsync_ShouldBeOk()
        {
            //arrange
            int expectedCount           = 1;
            List <TravelPackage> hotels = new List <TravelPackage>()
            {
                TravelPackageBuilder.Start().Build()
            };

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

            //action
            var callback = await _controller.Get();

            //assert
            var response = callback.Should().BeOfType <List <TravelPackage> >().Subject;

            response.Count.Should().Be(expectedCount);
        }