Exemplo n.º 1
0
        public async void ExistsFlightAsync_DeterminesWhetherFlightExistsCorrectly()
        {
            using (var mock = AutoMock.GetLoose())
            {
                // Mock the FindFlightsAsync method of IDataAccess to return an empty List<Flight>
                // on the first call and a populated list on the second call.
                mock.Mock <IDataAccess>()
                .SetupSequence(x => x.FindFlightsAsync(It.IsAny <Airport>(), It.IsAny <Airport>(), It.IsAny <DateTime>()))
                .ReturnsAsync(new List <Flight>())
                .ReturnsAsync(new List <Flight> {
                    new Flight(), new Flight()
                });

                FlightManager flightManager = mock.Create <FlightManager>();

                bool expected1 = false;
                bool expected2 = true;

                bool actual1 = await flightManager.ExistsFlightAsync(new Airport(), new Airport(), DateTime.Now);

                bool actual2 = await flightManager.ExistsFlightAsync(new Airport(), new Airport(), DateTime.Now);

                Assert.Equal(expected1, actual1);
                Assert.Equal(expected2, actual2);
            }
        }
        private void ItemsGet()
        {
            // Read sample item info from XML document into a DataSet
            try
            {
                // Populate the repeater control with the Items DataSet
                FlightManager   _flightManger = new FlightManager();
                PagedDataSource objPds        = new PagedDataSource();

                //CSPRBUG18.4 - Implementing Custom Collection
                //Flights - Custom Collection also Sorted with needed Interfaces
                //Custom Collection assigned to the data source of a control
                //As it is enumerable
                objPds.DataSource  = _flightManger.GetSortedFlights();
                objPds.AllowPaging = true;
                objPds.PageSize    = 3;

                objPds.CurrentPageIndex = CurrentPage;

                lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
                                      + objPds.PageCount.ToString();

                // Disable Prev or Next buttons if necessary
                commandPrevious.Enabled = !objPds.IsFirstPage;
                commandNext.Enabled     = !objPds.IsLastPage;

                dlFlight.DataSource = objPds;
                dlFlight.DataBind();
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
        public void FlightControllerDateTimeTest()
        {
            // Arrange
            var context = new Mock <HttpContext>();

            context.SetupGet(x => x.Request.QueryString).Returns(new QueryString("?"));

            var controllerContext = new ControllerContext()
            {
                HttpContext = context.Object,
            };
            var relative_to       = "Invalid_Date_Time";
            var stub              = new Mock <IScheduledCache>();
            var flightManager     = new FlightManager(stub.Object);
            var flightsController = new FlightsController(flightManager)
            {
                ControllerContext = controllerContext,
            };

            // Act
            var result = flightsController.GetFlightsAsync(relative_to, "");

            // Assert
            var action  = Assert.IsType <BadRequestObjectResult>(result.Result);
            var message = Assert.IsAssignableFrom <string>(action.Value);

            Assert.Equal("Date: Invalid_Date_Time has wrong format", message);
        }
Exemplo n.º 4
0
        private void ItemsGet()
        {
            // Read sample item info from XML document into a DataSet
            try
            {
                // Populate the repeater control with the Items DataSet
                FlightManager   _flightManger = new FlightManager();
                PagedDataSource objPds        = new PagedDataSource();
                objPds.DataSource  = _flightManger.GetFlights();
                objPds.AllowPaging = true;
                objPds.PageSize    = 3;

                objPds.CurrentPageIndex = CurrentPage;

                lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
                                      + objPds.PageCount.ToString();

                // Disable Prev or Next buttons if necessary
                commandPrevious.Enabled = !objPds.IsFirstPage;
                commandNext.Enabled     = !objPds.IsLastPage;

                dlFlight.DataSource = objPds;
                dlFlight.DataBind();
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
Exemplo n.º 5
0
 // Constructor with setup
 public MainWindowViewModel()
 {
     this.LoadHomePage();
     persMgr = PersonnelManager.Instance;
     jobMgr  = JobManager.Instance;
     fltMgr  = FlightManager.Instance;
 }
        public void BindData()
        {
            try
            {
                ddlAirLine.DataSource     = new AirLineManager().GetAirLines();
                ddlAirLine.DataTextField  = "Name";
                ddlAirLine.DataValueField = "Id";
                ddlAirLine.DataBind();

                flightid = Request.QueryString["flightid"].ToString();

                FlightManager obj = new FlightManager();
                flight = obj.GetFlight(int.Parse(flightid));

                FlightClass flightclass = new FlightClass();

                txtName.Text             = flight.Name;
                ddlAirLine.SelectedValue = flight.AirlineForFlight.Id.ToString();
                GridView1.DataSource     = flight.GetClasses();
                GridView1.DataBind();
            }

            catch (FlightManagerException ex)
            {
                throw ex;
            }
            catch (AirlineManagerException exc2)
            {
                throw exc2;
            }
        }
Exemplo n.º 7
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string flightName  = txtName.Text;
            int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
            string airlinename = ddlAirLine.SelectedItem.Text;
            Flight _flight     = new Flight()
            {
                Name = flightName, AirlineForFlight = new Airline()
                {
                    Id = airlineid, Name = airlinename
                }
            };
            FlightManager _flightManger = new FlightManager();

            try
            {
                foreach (RepeaterItem item in dlClass.Items)
                {
                    TextBox txtNoOfSeats = (TextBox)item.FindControl("txtNoOfSeats");
                    Label   lblClass     = (Label)item.FindControl("lblClass");

                    if (txtNoOfSeats.Text.Length == 0)
                    {
                        txtNoOfSeats.Focus();
                        lblError.Text = "No of Seats Cannot be Empty";
                        break;
                    }
                    else
                    {
                        if (txtNoOfSeats != null)
                        {
                            TravelClass travelClass = (TravelClass)Enum.Parse(typeof(TravelClass), lblClass.Text.Trim());
                            int         NoOfSeats   = int.Parse(txtNoOfSeats.Text);
                            FlightClass _class      = new FlightClass()
                            {
                                ClassInfo = travelClass, NoOfSeats = NoOfSeats
                            };
                            _flight.AddClass(_class);
                        }
                    }
                }
                if (_flightManger.AddFlight(_flight) == false)
                {
                    lblError.Text = "Flight Name already exists";
                }
                else
                {
                    lblError.Text = "Flight Added Successfully";
                }
            }
            catch (FlightManagerException exc)
            {
                lblError.Text = exc.Message;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
        public ActionResult <FlightPlan> Get(string id)
        {
            Console.WriteLine(id);
            Debug.WriteLine(id);
            FlightManager fm = new FlightManager();

            return(fm.GetFlightPlan(id).Result);
        }
Exemplo n.º 9
0
    // if player dead
    public override void OnDead(GameObject killer)
    {
        // if player dead call GameOver in GameManager
        FlightManager flight = (FlightManager)GameObject.FindObjectOfType(typeof(FlightManager));

        flight.GameOver();
        base.OnDead(killer);
    }
Exemplo n.º 10
0
        public FlightFixture() : base("TUI-Test-Flight")
        {
            var telemetryClient = new TelemetryClient();

            FlightManager   = new FlightManager(Context, telemetryClient);
            AirportManager  = new AirportManager(Context, telemetryClient);
            AircraftManager = new AircraftManager(Context, telemetryClient);
        }
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row = GridView1.Rows[e.RowIndex];

                if (((TextBox)row.FindControl("txtNoOfSeats")).Text.Length == 0)
                {
                    lblError.Text = "Seats Cannot be Empty";
                    ((TextBox)row.FindControl("txtNoOfSeats")).Focus();
                }
                else
                {
                    string txtClass     = ((TextBox)row.FindControl("txtClass")).Text;
                    int    txtNoOfSeats = Convert.ToInt32((((TextBox)row.FindControl("txtNoOfSeats")).Text.ToString()));

                    FlightClass _class = new FlightClass();
                    switch (txtClass)
                    {
                    case "Economy": _class.ClassInfo = TravelClass.Economy; break;

                    case "Business": _class.ClassInfo = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.NoOfSeats = txtNoOfSeats;

                    FlightManager _flightManger = new FlightManager();

                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };

                    _flightManger.UpdateFlightClass(_flight, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    lblError.Text = "Flight Seats Updated";
                }
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
Exemplo n.º 12
0
        public void Register(ContainerBuilder builder)
        {
            var flightDB         = new DbManager("flightbooking");
            var flightManager    = new FlightManager(flightDB);
            var passengerManager = new PassengerManager(flightDB);
            var bookingManager   = new BookingManager(flightDB, flightManager, passengerManager);


            builder.RegisterInstance <IFlightManager>(flightManager);
            builder.RegisterInstance <IBookingManager>(bookingManager);
            builder.RegisterInstance <IPassengerManager>(passengerManager);
        }
Exemplo n.º 13
0
        private async Task ResumeFlightSearchAfterHandler(IDialogContext context, IAwaitable <FlightSearchFormBasic> result)
        {
            var searchQuery = await result;
            var flights     = FlightManager.Flights(searchQuery);
            var response    = context.MakeMessage();

            response.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            response.Attachments      = AdaptiveCardManager.GetFlightsAdaptiveCards(flights);
            await context.PostAsync(response);

            context.Done <object>(null);
        }
Exemplo n.º 14
0
 public void Setup()
 {
     DouglasMD80 = new Plane("DouglasMD80", 2, 10);
     Cessina     = new Plane("Cessina", 6, 400);
     Boeing747   = new Plane("Boeing747", 100, 500);
     pass1       = new Passenger("Alice", 2);
     pass2       = new Passenger("John", 3);
     pass3       = new Passenger("Timmy", 4);
     BA213Time   = new TimeSpan(18, 00, 00);
     BA213       = new Flight(DouglasMD80, "BA213", "LON", "EDI", BA213Time);
     Flight1     = new FlightManager(BA213);
 }
Exemplo n.º 15
0
 public IHttpActionResult PutApproveFlight(int code, decimal actualBudget)
 {
     try
     {
         var result = FlightManager.ApproveFlight(code, actualBudget);
         return(Ok(result));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
Exemplo n.º 16
0
 public IHttpActionResult DeleteFlight(int code)
 {
     try
     {
         var result = FlightManager.DeleteFlight(code);
         return(Ok(result));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
Exemplo n.º 17
0
 public IHttpActionResult PutFlight(int code, decimal plannedBudget, string comment)
 {
     try
     {
         var result = FlightManager.UpdateFlight(code, plannedBudget, comment);
         return(Ok(result));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
Exemplo n.º 18
0
 public IHttpActionResult PostFlightPlan(int code)
 {
     try
     {
         var result = FlightManager.GetFlightPlan(code);
         return(Ok(result));
     }
     catch (Exception)
     {
         return(NotFound());
     }
 }
Exemplo n.º 19
0
    void Start()
    {
        play   = (PlayerController)GameObject.FindObjectOfType(typeof(PlayerController));
        weapon = play.GetComponent <WeaponController> ();
        fligh  = (FlightManager)GameObject.FindObjectOfType(typeof(FlightManager));
        fligh.ClearDate();

        // define player
        if (isUgui)
        {
            ShowUGUI();
        }
    }
Exemplo n.º 20
0
        public static void InitializeFlyPoints()
        {
            FlightManager.ClearFlightPoints();

            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 0, Name = "Florea Town", MapNumber = 5, ImageName = "florea.png", Description = "Where everything blooms beautifully."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 1, Name = "Newpond Village", MapNumber = 54, ImageName = "newpond.png", Description = "Fresh air and fresh water."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 2, Name = "Dream Village", MapNumber = 35, ImageName = "dream village.png", Description = "Hidden within the cherry blossoms."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 3, Name = "Borealis City", MapNumber = 224, ImageName = "borealis.png", Description = "A city that rose from a glorious history."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 4, Name = "Mysveil Town", MapNumber = 358, ImageName = "mysveil.png", Description = "Beyond the veil of time."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 5, Name = "Moonhaven", MapNumber = 490, ImageName = "moonhaven.png", Description = "A friendly bat town located inside a long-dormant ocean volcano."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 6, Name = "Bayside Bazaar", MapNumber = 258, Description = "The bazaar down by the bay!"
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 7, Name = "Aurora Highland", MapNumber = 246, ImageName = "aurora highlands.png", Description = "The mountains of Aurora."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 8, Name = "Debug", MapNumber = 1, Description = "Test unreleased content here."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 9, Name = "Isle of Life", MapNumber = 477, Description = "A sacred island known to hold mythical powers."
            });
            FlightManager.AddFlightPoint(new FlightPoint()
            {
                ID = 10, Name = "Somoria", MapNumber = 1189, Description = "A home for nocturnal pokemon."
            });
        }
Exemplo n.º 21
0
        public NewEmployeeViewModel(Employee employee, PersonnelManager persMgr, FlightManager fltMgr)
        {
            if (employee == null)
            {
                throw new ArgumentNullException("employee");
            }

            _employee = employee;
            _persMgr  = persMgr;
            _fltMgr   = fltMgr;

            IList <Flight> f = _fltMgr.GetAllFlights();

            this._flights = new CollectionView(f);
        }
Exemplo n.º 22
0
    // if Enemy on Dead
    public override void OnDead(GameObject killer)
    {
        if (killer)        // check if killer is exist
                           // check if PlayerManager are included.
        {
            if (killer.gameObject.GetComponent <PlayerManager>())
            {
                // find gameMAnager and Add score

                FlightManager fligh = (FlightManager)GameObject.FindObjectOfType(typeof(FlightManager));
                fligh.AddKilled();
            }
        }
        base.OnDead(killer);
    }
Exemplo n.º 23
0
        public ActionResult <List <Flights> > Get(DateTimeOffset relative_to)
        {
            //List<Flights>
            try
            {
                FlightManager f           = new FlightManager();
                string        queryString = Request.QueryString.Value;
                string        relativeTo  = relative_to.ToString();

                return(f.getFlightsList(cache, queryString, relativeTo));
            }
            catch (Exception e)
            {
                return(NotFound(e.Message));
            }
        }
Exemplo n.º 24
0
    // Use this for initialization
    void Start()
    {
        // Initialize the Game Time to 8 AM, some day. This may be updated by the
        // game level in the future.
        time = new System.DateTime(2020, 4, 12, 8, 0, 0, 0);

        // Initialize the daily flights list
        dailyFlights  = new List <Flight>();
        dailyArrivals = new List <Flight>();

// Populate both daily flight lists through FlightManager.
        FlightManager.PopulateDailyDepartures(dailyFlights);
        FlightManager.PopulateDailyArrivals(dailyArrivals);

        AirportController.instance = this;
    }
Exemplo n.º 25
0
        public ActionResult <List <Flight> > GetInternal([FromQuery(Name = "relative_to")] DateTime time)
        {
            time = time.ToUniversalTime();
            FlightManager fm = new FlightManager();

            if (Request.Query.ContainsKey("sync_all"))
            {
                try
                {
                    return(fm.getAllFlights(time).Result);
                }
                catch
                {
                }
            }
            return(fm.getInternal(time));
        }
Exemplo n.º 26
0
        public bool IsValidPlayerSpawn(string mapID)
        {
            //Messenger.PlayerMsg(Client, "2", Text.Black);
            if (string.IsNullOrEmpty(mapID))
            {
                return(false);
            }
            var map = MapManager.RetrieveMap(mapID);

            switch (map.MapType)
            {
            case Enums.MapType.House:
            {
                var houseMap = (House)map;

                return(houseMap.OwnerID == Client.Player.CharID);
            }

            case Enums.MapType.GuildBase:
            {
                var guildBaseMap = (GuildBase)map;

                return(Client.Player.GuildId == guildBaseMap.Owner);
            }

            case Enums.MapType.Standard:
            {
                if (!mapID.StartsWith("s"))
                {
                    return(false);
                }

                var mapNumber = mapID.Substring(1, mapID.Length - 1).ToInt();

                var flightPoint = FlightManager.FindFlightPoint(mapNumber);

                return(flightPoint != null);
            }
            }

            return(false);
        }
Exemplo n.º 27
0
        protected void dpAirlineName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                dpFlightName.Items.Clear();
                FlightManager objairline = new FlightManager();
                List <Flight> flightlist = objairline.GetFlightsForAirLine(int.Parse(dpAirlineName.SelectedValue));

                foreach (Flight c in flightlist)
                {
                    ListItem item = new ListItem(c.Name, c.ID.ToString());
                    dpFlightName.Items.Add(item);
                }
                dpFlightName.DataBind();
            }
            catch (FlightManagerException exc)
            {
                throw exc;
            }
        }
Exemplo n.º 28
0
        public static void Main(string[] args)
        {
            var fm = new FlightManager();

            var flights = fm.FindByRoute("Vienna", "London");

            foreach (var flight in flights)
            {
                Console.WriteLine(flight.Id + ", " + flight.Date);
            }

            var f = fm.FindById(1);

            fm.Update(f);

            fm.ShowShadowState();

            Console.WriteLine("Done.");
            Console.ReadLine();
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            AirspaceArea area = new AirspaceArea(10000, 10000, 90000, 90000, 500, 20000);

            ITransponderReceiver   transponderReceiver = TransponderReceiverFactory.CreateTransponderDataReceiver();
            IFlightTrackDataSource dataConverter       = new DataConverter(transponderReceiver);
            IFlightTrackerMultiple flightManager       = new FlightManager(dataConverter);

            ISeperationManager seperationController = new SeperationController(flightManager);
            //SeperationHandler sepHandl = new SeperationHandler(seperationController, flightManager);

            IAirspace airspace = new Airspace(flightManager, area);

            //Monitor monitor = new Monitor(airspace, seperationController);
            while (true)
            {
                Thread.Sleep(150);
            }
            ;
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length == 0)
            {
                lblError.Text = "Flight Name Can't be Empty";
                txtName.Focus();
            }
            else
            {
                try
                {
                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };
                    FlightManager _flightManger = new FlightManager();

                    if (_flightManger.UpdateFlight(_flight))
                    {
                        lblError.Text = "Flight Updated";
                    }
                    else
                    {
                        lblError.Text = "Unable to updated Flight";
                    }
                }
                catch (FlightManagerException ex)
                {
                    lblError.Text = ex.Message;
                }
            }
        }