public void should_generate_flights_based_on_charter_schedule_when_arrive_is_different_from_depart() { var schedule = new CharterSchedule("Qatar Airways", "Airbus", "4070", 250); var depart1 = TimeSpan.Parse("21:00"); var arrive1 = TimeSpan.Parse("03:00"); schedule.AddTimeTable(new CharterTimeTable(DayOfWeek.Monday, "IKA", "HKT", depart1, arrive1)); var start = DateTime.Parse("2019-08-19"); //Monday var end = DateTime.Parse("2019-08-22"); var expected = new List <Flight>() { new Flight() { Origin = "IKA", Destination = "HKT", FlightNo = "4070", Depart = DateTime.Parse("2019-08-19 21:00:00"), Arrive = DateTime.Parse("2019-08-20 03:00:00"), }, }; var actual = FlightGenerationService.Generate(start, end, schedule); actual.Should().BeEquivalentTo(expected); }
public void Generate_should_generate_flights_based_on_request_and_save_them() { #region Using-Mock //var repository = Substitute.For<IFlightRepository>(); //var calculationService = Substitute.For<IFlightCalculationService>(); //var flights = SomeFlights(); //calculationService.Calculate(Arg.Any<FlightCalculationRequest>()).Returns(flights); //var service = new FlightGenerationService(repository, calculationService); //service.Generate(new FlightCalculationRequest()); //repository.Received(3).Add(Arg.Any<Flight>()); #endregion var repository = new FakeFlightRepository(); var calculationService = Substitute.For <IFlightCalculationService>(); var flights = SomeFlights(); calculationService.Calculate(Arg.Any <FlightCalculationRequest>()).Returns(flights); var service = new FlightGenerationService(repository, calculationService); service.Generate(new FlightCalculationRequestDto()); var actualInsertedFlights = repository.GetFlights(); actualInsertedFlights.Should().BeEquivalentTo(flights); }
public void should_generate_flights_based_on_charter_schedule_when_arrive_is_in_same_day_as_depart() { var schedule = new CharterScheduleBuilder() .WithFlightNo("4070") .WithTimeTable(DayOfWeek.Monday, IKA, HKT, "05:00", "10:00") .WithTimeTable(DayOfWeek.Wednesday, HKT, IKA, "15:00", "20:00") .Build(); var start = DateTime.Parse("2019-08-19"); //Monday var end = DateTime.Parse("2019-08-26"); var expected = new List <Flight>() { new Flight() { Origin = IKA, Destination = HKT, FlightNo = "4070", Depart = DateTime.Parse("2019-08-19 05:00:00"), Arrive = DateTime.Parse("2019-08-19 10:00:00"), }, new Flight() { Origin = HKT, Destination = IKA, FlightNo = "4070", Depart = DateTime.Parse("2019-08-21 15:00:00"), Arrive = DateTime.Parse("2019-08-21 20:00:00"), }, new Flight() { Origin = IKA, Destination = HKT, FlightNo = "4070", Depart = DateTime.Parse("2019-08-26 05:00:00"), Arrive = DateTime.Parse("2019-08-26 10:00:00"), }, }; var actual = FlightGenerationService.Generate(start, end, schedule); actual.Should().BeEquivalentTo(expected); }