Ejemplo n.º 1
0
 public StopController(IWorldRepository repository, ILogger <StopController> logger,
                       CoordinateService coordinateService)
 {
     _repository        = repository;
     _logger            = logger;
     _coordinateService = coordinateService;
 }
Ejemplo n.º 2
0
        public void GetKmDistanceTest()
        {
            var coordinatiorService = new CoordinateService();
            var pedido   = SetupTests.GetPedido();
            var distance = coordinatiorService.GetKmDistance(pedido.GetPoint(), new Point());

            Assert.True(distance == 489.8);
        }
Ejemplo n.º 3
0
        public void CreateCoordinate_InputCoordinates_ReturnsCoordinateNotNull()
        {
            var coordinateService = new CoordinateService();
            var coordinate        = coordinateService.Create(0, 0);
            var result            = coordinate.X;

            Assert.Equal(0, result);
        }
Ejemplo n.º 4
0
        public void CreateCoordinate_InputCoordinates_ReturnsCoordinateY(int x, int y, int expectedValue)
        {
            var coordinateService = new CoordinateService();
            var coordinate        = coordinateService.Create(x, y);
            var result            = coordinate.X;

            Assert.Equal(expectedValue, result);
        }
Ejemplo n.º 5
0
 public StopController(IWorldRepository _repository,
                       ILogger <StopController> _logger,
                       CoordinateService _coordinateService)
 {
     repository        = _repository;
     logger            = _logger;
     coordinateService = _coordinateService;
 }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            var robot = Core.Initialize();
            ICoordinateService coordinateService = new CoordinateService();

            Execute(robot, coordinateService);

            WriteLine(robot.Report);
            ReadLine();
        }
        public void SaveList_ShouldUpdateIfIdIsGiven()
        {
            //arrange
            var service = new CoordinateService(_cooRepoListMock.Object);

            //act
            service.SaveList(new Entities.CoordinateList(50, "test", null)).Wait();

            _cooRepoListMock.Verify(c => c.UpdateAsync(It.IsAny <Entities.CoordinateList>()), Times.Once);
            _cooRepoListMock.Verify(c => c.CreateAsync(It.IsAny <Entities.CoordinateList>()), Times.Never);
        }
Ejemplo n.º 8
0
        public void should_test_round_clean()
        {
            _coordinates = new List <Coordinate> {
                new Coordinate("E 1"), new Coordinate("N 1"), new Coordinate("W 1"), new Coordinate("S 1")
            };
            _robot = new Robot(_position, _coordinates);
            var coordinateService = new CoordinateService();

            Program.Execute(_robot, coordinateService);

            Assert.AreEqual(_robot.Report, "=> Cleaned: 4");
        }
Ejemplo n.º 9
0
        public void should_raise_exception()
        {
            var coordinate = new Coordinate("X 2");

            _robot.Commands = new List <Coordinate> {
                coordinate
            };

            var coordinateService = new CoordinateService();

            Assert.Throws <ArgumentException>(() => coordinateService.ExecuteSteps(_robot, coordinate));
        }
Ejemplo n.º 10
0
        public void should_test_cint_solution()
        {
            _position    = new Position(10, 22);
            _coordinates = new List <Coordinate> {
                new Coordinate("E 2"), new Coordinate("N 1")
            };
            _robot = new Robot(_position, _coordinates);
            var coordinateService = new CoordinateService();

            Program.Execute(_robot, coordinateService);

            Assert.AreEqual(_robot.Report, "=> Cleaned: 4");
        }
Ejemplo n.º 11
0
        public void ConsultarStatusDrone()
        {
            var coordinateService = new CoordinateService();
            IPedidoDroneRepository pedidoDroneRepository = null;
            var context         = Substitute.For <DataContext>();
            var droneRepository = new MockDroneRepository(context);
            PedidoRepository pedidoRepository = null;

            var droneService = new DroneService(coordinateService, pedidoDroneRepository, droneRepository, pedidoRepository);

            var droneStatus = droneService.GetDroneStatus();

            Assert.Equal <int>(2, droneStatus.Count);
        }
        public void SaveList_ShouldNotOverrideIfListDoesNotExists()
        {
            //arrange
            const string testListName = "testNew";
            var          service      = new CoordinateService(_cooRepoListMock.Object);

            _cooRepoListMock.Setup(c => c.GetAsync(testListName)).Returns(Task.FromResult <Entities.CoordinateList>(null));

            //act
            service.SaveList(new Entities.CoordinateList(0, testListName, null)).Wait();

            _cooRepoListMock.Verify(c => c.CreateAsync(It.IsAny <Entities.CoordinateList>()), Times.Once);
            _cooRepoListMock.Verify(c => c.UpdateAsync(It.IsAny <Entities.CoordinateList>()), Times.Never);
        }
        public void ConsultarStatusDrone()
        {
            ICoordinateService     coordinateService     = new CoordinateService();
            IPedidoDroneRepository pedidoDroneRepository = null;
            IDroneRepository       droneRepository       = new MockDroneRepository();

            IPedidoRepository pedidoRepository = null;

            IDroneService droneService = new DroneService(coordinateService, pedidoDroneRepository, droneRepository, pedidoRepository);

            droneService.GetDroneStatusAsync();

            Assert.Equal <int>(2, droneService.GetDroneStatusAsync().Count);
        }
Ejemplo n.º 14
0
        public void NextTurn(GameBoard opponentBoard)
        {
            while (true)
            {
                var randomCoordinate = CoordinateService.GetRandomCoordinate();
                var randomCell       = opponentBoard.Cells[randomCoordinate.Row][randomCoordinate.Column];
                if (randomCell.IsHit)
                {
                    continue;
                }

                opponentBoard.TakeHit(randomCell.Coordinate);
                break;
            }
        }
Ejemplo n.º 15
0
        public void should_move_towards()
        {
            var coordinate = new Coordinate("E 2");

            _robot.Commands = new List <Coordinate> {
                coordinate
            };

            var coordinateService = new CoordinateService();

            coordinateService.ExecuteSteps(_robot, coordinate);

            var expected = new Position(2, 0);

            Assert.AreEqual(_robot.Position.PositionX, expected.PositionX);
            Assert.AreEqual(_robot.Position.PositionY, expected.PositionY);
        }
        private void SetupServicesIfNeeded()
        {
            if (servcicesInitialized == false)
            {
                noNetworkString = LangUtil.Get("Error.NoResponse");

                regEmailSMSService = new RegEmailSMSService();

                coordinateService = new CoordinateService();
                coordinateService.AddLanguageValue(CoordinateServiceLanguageKey.Coordinate_North, LangUtil.Get("Element.North.Text"));
                coordinateService.AddLanguageValue(CoordinateServiceLanguageKey.Coordinate_South, LangUtil.Get("Element.South.Text"));
                coordinateService.AddLanguageValue(CoordinateServiceLanguageKey.Coordinate_East, LangUtil.Get("Element.East.Text"));
                coordinateService.AddLanguageValue(CoordinateServiceLanguageKey.Coordinate_West, LangUtil.Get("Element.West.Text"));
                coordinateService.AddLanguageValue(CoordinateServiceLanguageKey.Coordinate_Degrees, LangUtil.Get("Element.Degrees.Text"));
                coordinateService.AddLanguageValue(CoordinateServiceLanguageKey.Coordinate_Minutes, LangUtil.Get("Element.Minutes.Text"));
                coordinateService.AddLanguageValue(CoordinateServiceLanguageKey.Coordinate_Seconds, LangUtil.Get("Element.Seconds.Text"));
                servcicesInitialized = true;
            }
        }
Ejemplo n.º 17
0
        private void _download_Click(object sender, EventArgs e)
        {
            try
            {
                ClientSecrets cs = new ClientSecrets();
                cs.ClientId = "728822159738-252ghnvc1l1kjssq0d6dtrf2h2t48ihp.apps.googleusercontent.com";
                cs.ClientSecret = "lO67xySyeUClGRYmwQ1LIyee";


                UserCredential uc = GoogleWebAuthorizationBroker.AuthorizeAsync(cs, new string[] { Google.Apis.Coordinate.v1.CoordinateService.Scope.Coordinate }, "user", System.Threading.CancellationToken.None, new FileDataStore("Timelines.MyLibrary")).Result;

                var coordinateService = new CoordinateService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = uc,
                    ApplicationName = "Google maps timeline downloader"
                });


                // ここからどうすんだ?

                /*
                Google.Apis.Http.ConfigurableHttpClient http = coordinateService.HttpClient;

                DateTime target = dateTimePicker1.Value;

                string targetUrl = string.Format("https://www.google.com/maps/timeline/kml?authuser=0&pb=!1m8!1m3!1i{0}!2i{1}!3i{2}!2m3!1i{0}!2i{1}!3i{2}", target.Year, target.Month - 1, target.Day);

                System.Net.Http.HttpResponseMessage res = http.SendAsync(new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, targetUrl)).Result;

                string result = res.Content.ReadAsStringAsync().Result;

                System.Diagnostics.Debug.Print(result);
                */

            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw;
            }
        }
Ejemplo n.º 18
0
        private void _download_Click(object sender, EventArgs e)
        {
            try
            {
                ClientSecrets cs = new ClientSecrets();
                cs.ClientId     = "728822159738-252ghnvc1l1kjssq0d6dtrf2h2t48ihp.apps.googleusercontent.com";
                cs.ClientSecret = "lO67xySyeUClGRYmwQ1LIyee";


                UserCredential uc = GoogleWebAuthorizationBroker.AuthorizeAsync(cs, new string[] { Google.Apis.Coordinate.v1.CoordinateService.Scope.Coordinate }, "user", System.Threading.CancellationToken.None, new FileDataStore("Timelines.MyLibrary")).Result;

                var coordinateService = new CoordinateService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = uc,
                    ApplicationName       = "Google maps timeline downloader"
                });


                // ここからどうすんだ?

                /*
                 * Google.Apis.Http.ConfigurableHttpClient http = coordinateService.HttpClient;
                 *
                 * DateTime target = dateTimePicker1.Value;
                 *
                 * string targetUrl = string.Format("https://www.google.com/maps/timeline/kml?authuser=0&pb=!1m8!1m3!1i{0}!2i{1}!3i{2}!2m3!1i{0}!2i{1}!3i{2}", target.Year, target.Month - 1, target.Day);
                 *
                 * System.Net.Http.HttpResponseMessage res = http.SendAsync(new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, targetUrl)).Result;
                 *
                 * string result = res.Content.ReadAsStringAsync().Result;
                 *
                 * System.Diagnostics.Debug.Print(result);
                 */
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                throw;
            }
        }
Ejemplo n.º 19
0
        public static void Main(string[] args)
        {
            // TO UPDATE, can be found in the Coordinate application URL
            String TEAM_ID = "jskdQ--xKjFiFqLO-IpIlg";

            // Register the authenticator.
            var provider = new WebServerClient(GoogleAuthenticationServer.Description);

            // TO UPDATE, can be found in the APIs Console.
            provider.ClientIdentifier = "335858260352.apps.googleusercontent.com";
            // TO UPDATE, can be found in the APIs Console.
            provider.ClientSecret = "yAMx-sR[truncated]fX9ghtPRI";
            var auth = new OAuth2Authenticator <WebServerClient> (provider, GetAuthorization);

            // Create the service.
            var service = new CoordinateService(new BaseClientService.Initializer()
            {
                Authenticator = auth
            });

            //Create a Job Resource for optional parameters https://developers.google.com/coordinate/v1/jobs#resource
            Job jobBody = new Job();

            jobBody.Kind           = "Coordinate#job";
            jobBody.State          = new JobState();
            jobBody.State.Kind     = "coordinate#jobState";
            jobBody.State.Assignee = "*****@*****.**";


            //Create the Job
            JobsResource.InsertRequest ins = service.Jobs.Insert(jobBody, TEAM_ID, "My Home", "51", "0", "Created this Job with the .Net Client Library");
            Job results = ins.Fetch();

            //Display the response
            Console.WriteLine("Job ID:");
            Console.WriteLine(results.Id.ToString());
            Console.WriteLine("Press any Key to Continue");
            Console.ReadKey();
        }
Ejemplo n.º 20
0
        static void Main(string[] args)
        {
            CoordinateService coordService     = new CoordinateService();
            decimal           width            = -1;
            decimal           height           = -1;
            decimal           sideLength       = -1;
            bool properGraphCoordinatesEntered = false;
            bool requestSpecificTriangle       = true;

            while (!properGraphCoordinatesEntered)
            {
                while (width == -1)
                {
                    Console.WriteLine("Please enter the width of the image:");
                    var widthInput = Console.ReadLine();

                    if (!Decimal.TryParse(widthInput, out width))
                    {
                        Console.WriteLine("Please enter a numeric only value for the width.");
                    }
                }

                while (height == -1)
                {
                    Console.WriteLine("Please enter the height of the image:");
                    var heightInput = Console.ReadLine();

                    if (!Decimal.TryParse(heightInput, out height))
                    {
                        Console.WriteLine("Please enter a numeric only value for the height.");
                    }
                }

                while (sideLength == -1)
                {
                    Console.WriteLine("Please enter the length of each side of each image graph section:");
                    var sideLengthInput = Console.ReadLine();

                    if (!Decimal.TryParse(sideLengthInput, out sideLength))
                    {
                        Console.WriteLine("Please enter a numeric only value for the side length of each graph section.");
                    }
                }

                properGraphCoordinatesEntered = coordService.GenerateGraph(width, height, sideLength);

                if (!properGraphCoordinatesEntered)
                {
                    Console.WriteLine("Invalid parameters entered to generate a graph with graph sections of the same size.  Please input new parameters.");
                }

                foreach (var Triangle in coordService.Triangles)
                {
                    Console.WriteLine(Triangle.TriangleName + ":");
                    Console.WriteLine("V1: {" + Triangle.V1.X + "," + Triangle.V1.Y + "}");
                    Console.WriteLine("V2: {" + Triangle.V2.X + "," + Triangle.V2.Y + "}");
                    Console.WriteLine("V3: {" + Triangle.V3.X + "," + Triangle.V3.Y + "}");
                    Console.WriteLine(" ");
                }
            }

            while (requestSpecificTriangle)
            {
                Console.WriteLine("Would you like to find a specific triangle in the graph (Y or N)?  Any other input will exit the application.");
                var requestSpecificTriangleAnswer = Console.ReadLine();

                if (requestSpecificTriangleAnswer.ToUpper() == "Y")
                {
                    var   ProperV1 = false;
                    var   ProperV2 = false;
                    var   ProperV3 = false;
                    int   XCoord;
                    int   YCoord;
                    Point V1 = new Point();
                    Point V2 = new Point();
                    Point V3 = new Point();


                    while (!ProperV1)
                    {
                        Console.WriteLine("Input coordinates for V1 as X and Y separated by a space:");
                        var V1Coordinates = Console.ReadLine().Split(' ');

                        if (V1Coordinates.Count() == 2 && Int32.TryParse(V1Coordinates[0], out XCoord) && Int32.TryParse(V1Coordinates[1], out YCoord))
                        {
                            ProperV1 = true;
                            V1       = new Point {
                                X = XCoord, Y = YCoord
                            };
                        }
                        else
                        {
                            Console.WriteLine("Invalid V1 Coordinates, please re-enter.");
                        }
                    }

                    while (!ProperV2)
                    {
                        Console.WriteLine("Input coordinates for V2 as X and Y separated by a space:");
                        var V2Coordinates = Console.ReadLine().Split(' ');

                        if (V2Coordinates.Count() == 2 && Int32.TryParse(V2Coordinates[0], out XCoord) && Int32.TryParse(V2Coordinates[1], out YCoord))
                        {
                            ProperV2 = true;
                            V2       = new Point {
                                X = XCoord, Y = YCoord
                            };
                        }
                        else
                        {
                            Console.WriteLine("Invalid V2 Coordinates, please re-enter.");
                        }
                    }

                    while (!ProperV3)
                    {
                        Console.WriteLine("Input coordinates for V3 as X and Y separated by a space:");
                        var V3Coordinates = Console.ReadLine().Split(' ');

                        if (V3Coordinates.Count() == 2 && Int32.TryParse(V3Coordinates[0], out XCoord) && Int32.TryParse(V3Coordinates[1], out YCoord))
                        {
                            ProperV3 = true;
                            V3       = new Point {
                                X = XCoord, Y = YCoord
                            };
                        }
                        else
                        {
                            Console.WriteLine("Invalid V3 Coordinates, please re-enter.");
                        }
                    }

                    Console.WriteLine(coordService.FindCoordinateTriangle(V1, V2, V3));
                }
                else
                {
                    requestSpecificTriangle = false;
                }
            }
        }
Ejemplo n.º 21
0
 public void SetUp()
 {
     _coordinateService = new CoordinateService();
 }
Ejemplo n.º 22
0
 public void SetUp()
 {
     _coordinateService = new CoordinateService();
     _3X3Config         = MapConfig.Create(3, 3);
 }
Ejemplo n.º 23
0
 public StopsController(TripContext tc, CoordinateService c)
 {
     db = tc;
     cs = c;
 }
 public AndroidApplicationService(string databaseName = "snladata") : base()
 {
     CoordinateService = new CoordinateService();
 }
Ejemplo n.º 25
0
 public StopsController(TripContext tp, CoordinateService service)
 {
     db = tp;
     cs = service;
 }