示例#1
0
        private static void GprsProvider_GprsIpAppsBearerStateChanged(bool isOpen)
        {
            if (isOpen)
            {
                // launch a new thread to get time and location from network
                new Thread(() =>
                {
                    Thread.Sleep(1000);

                    LocationAndTime lt = SIM800H.GetTimeAndLocation();

                    if (lt.ErrorCode == 0)
                    {
                        // request successfull
                        Debug.Print("Network time " + lt.DateTime.ToString() + " GMT");
                        Debug.Print("Location http://www.bing.com/maps/?v=2&form=LMLTSN&cp=" + lt.Latitude.ToString() + "~" + lt.Longitude.ToString() + "&lvl=17&sty=r&encType=1");
                    }
                    else
                    {
                        // failed to retrieve time and location from network
                        Debug.Print("### Failed to retrieve time and location from network. Error code: " + lt.ErrorCode.ToString() + " ###");
                    }
                }).Start();
            }
        }
        // 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);
        }
        internal async Task <Location> GetCurrentLocation(TimePassed accuracy)
        {
            if (!this.CheckIfNewLocationRequired(accuracy))
            {
                return(this.cachedLocation.Location);
            }

            GeolocationRequest request  = new GeolocationRequest(GeolocationAccuracy.Medium);
            Location           location = await Geolocation.GetLocationAsync(request);

            this.cachedLocation = new LocationAndTime()
            {
                Location = location,
                DateTime = System.DateTime.Now
            };

            return(location);
        }
        // a help function - called from the task of GetSampleFlightPlan
        private FlightPlan GetAsyncSampleFlightPlan(string id)
        {
            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.Flight_Id        = id;
            flightPlan.Passengers       = 50;
            flightPlan.Company_Name     = "comp-name";
            flightPlan.Initial_Location = location;
            flightPlan.Segments         = list;

            return(flightPlan);
        }