// test for IsValidFlightPlan function. // in this scenario - we are adding legal flight and expect to get true as a return value. public void IsValidFlightPlanFullFlightReturnsTrue() { // Arrange //new FlightPlan. var flightPlan = new FlightPlan(); //new segment list. List <Segment> list = new List <Segment>(); var segments = new Segment(); segments.Latitude = 31.12; segments.Longitude = 33.16; segments.Timespan_seconds = 500; list.Add(segments); //new location. var location = new LocationAndTime(16, 14, new DateTime()); flightPlan.Passengers = 50; flightPlan.Company_Name = "comp-name"; flightPlan.Initial_Location = location; flightPlan.Segments = list; //creating flightPlanController var flightPlanTester = new FlightPlanController(new FlightControlManager()); // Act var result = flightPlan.IsValidFlightPlan(); // Assert Assert.IsTrue(result); }
// adding a new FlightPlan. public ActionResult AddFlightPlan([FromBody] FlightPlan flightPlan) { // checking if valid. if (flightPlan.IsValidFlightPlan()) { flightPlan.Initial_Location.StartTime = flightPlan.Initial_Location.StartTime.ToUniversalTime(); this.flightControlManager.AddFlightPlan(flightPlan); return(Ok("Flight Id: " + flightPlan.Flight_Id)); } return(BadRequest("Invalid FlightPlan")); }