public void GetsLocatorsForAllGrids()
            {
                var command = new ParseAddressCommand("326 east south temple");

                command.Run();

                var parsedAddress = command.Result;

                var command2 = new ParseZoneCommand("84111", new GeocodeAddress(parsedAddress));

                command2.Run();

                var address = command2.Result;

                address.AddressGrids = new List <GridLinkable>
                {
                    new ZipGridLink(84111, "grid_1", 0),
                    new ZipGridLink(84111, "grid_2", 1)
                };

                App.GridsWithAddressPoints = new string[] {};

                var result = CommandExecutor.ExecuteCommand(new GetLocatorsForAddressCommand(address, new GeocodeOptions
                {
                    AcceptScore  = 70,
                    JsonFormat   = JsonFormat.None,
                    Locators     = LocatorType.All,
                    SuggestCount = 0,
                    WkId         = 26912
                }));

                Assert.That(result.Count, Is.EqualTo(8));
                Assert.That(result.Select(x => x.Url), Is.EquivalentTo(new[]
                {
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                    ,
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                    ,
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS1/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                    ,
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS2/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                    ,
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                    ,
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                    ,
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS1/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                    ,
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS2/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                }).IgnoreCase);
            }
 public GeocodeAddressController(ParseAddressCommand parseAddressCommand, ParseZoneCommand parseZoneCommand,
                                 GetLocatorsForAddressCommand locatorCommand, LocatePoBoxCommand poboxCommand,
                                 UspsDeliveryPointCommand deliveryPointCommand, IHttpClientFactory clientFactory)
 {
     _parseAddressCommand          = parseAddressCommand;
     _parseZoneCommand             = parseZoneCommand;
     _getLocatorsForAddressCommand = locatorCommand;
     _poboxCommand         = poboxCommand;
     _deliveryPointCommand = deliveryPointCommand;
     _clientFactory        = clientFactory;
 }
            public void GetsLocatorsForAddressReversal()
            {
                var command = new ParseAddressCommand("400 S 532 E");

                command.Run();

                var parsedAddress = command.Result;

                var command2 = new ParseZoneCommand("84111", new GeocodeAddress(parsedAddress));

                command2.Run();

                var address = command2.Result;

                address.AddressGrids = new List <GridLinkable>
                {
                    new ZipGridLink(84111, "grid_1", 0)
                };

                App.GridsWithAddressPoints = new[]
                {
                    "grid_1"
                };

                var result = CommandExecutor.ExecuteCommand(new GetLocatorsForAddressCommand(address, new GeocodeOptions
                {
                    AcceptScore  = 70,
                    JsonFormat   = JsonFormat.None,
                    Locators     = LocatorType.All,
                    SuggestCount = 0,
                    WkId         = 26912
                }));

                Assert.That(result.Count, Is.EqualTo(6));
                Assert.That(result.Select(x => x.Url), Is.EquivalentTo(new[]
                {
                    "http://localhost/arcgis/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=532+East+400+South&City=grid_1&outSR=26912",
                    "http://localhost/arcgis/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=400+South+532+East&City=grid_1&outSR=26912",
                    "http://localhost/arcgis/rest/services/Geolocators/AddressPoints_AddressSystem/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=400+South+532+East&City=grid_1&outSR=26912",
                    "http://localhost/arcgis/rest/services/Geolocators/AddressPoints_AddressSystem/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=532+East+400+South&City=grid_1&outSR=26912",
                    "http://localhost/arcgis/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=532+East+400+South&City=grid_1&outSR=26912",
                    "http://localhost/arcgis/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=400+South+532+East&City=grid_1&outSR=26912"
                }));
            }
            public void GetsLocatorsForPossibleAddressReversal()
            {
                var command = new ParseAddressCommand("5625 S 995 E");

                command.Run();

                var parsedAddress = command.Result;

                var command2 = new ParseZoneCommand("84111", new GeocodeAddress(parsedAddress));

                command2.Run();

                var address = command2.Result;

                address.AddressGrids = new List <GridLinkable>
                {
                    new ZipGridLink(84111, "SALT LAKE CITY", 0)
                };

                var result = CommandExecutor.ExecuteCommand(new GetLocatorsForAddressCommand(address, new GeocodeOptions
                {
                    AcceptScore  = 70,
                    JsonFormat   = JsonFormat.None,
                    Locators     = LocatorType.All,
                    SuggestCount = 0,
                    WkId         = 26912
                }));

                Assert.That(result.Count, Is.EqualTo(8));
                Assert.That(result.Select(x => x.Url), Is.EquivalentTo(new[]
                {
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=995+East+5625+South&City=SALT LAKE CITY&outSR=26912",
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=995+East+5625+South&City=SALT LAKE CITY&outSR=26912",
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=5625+South+995+East&City=SALT LAKE CITY&outSR=26912",
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=5625+South+995+East&City=SALT LAKE CITY&outSR=26912",
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS1/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=5625+South+995+East&City=SALT LAKE CITY&outSR=26912",
                    "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS2/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=5625+South+995+East&City=SALT LAKE CITY&outSR=26912",
                    "http://localhost/ArcGIS/rest/services/Geolocators/AddressPoints_AddressSystem/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=995+East+5625+South&City=SALT LAKE CITY&outSR=26912",
                    "http://localhost/ArcGIS/rest/services/Geolocators/AddressPoints_AddressSystem/" +
                    "GeocodeServer/findAddressCandidates?f=json&Street=5625+South+995+East&City=SALT LAKE CITY&outSR=26912"
                }).IgnoreCase);
            }
            public void GetsLocatorsForAddressReversal()
            {
                var command = new ParseAddressCommand("400 S 532 E");
                command.Run();

                var parsedAddress = command.Result;

                var command2 = new ParseZoneCommand("84111", new GeocodeAddress(parsedAddress));
                command2.Run();

                var address = command2.Result;

                address.AddressGrids = new List<GridLinkable>
                    {
                        new ZipGridLink(84111, "grid_1", 0)
                    };

                App.GridsWithAddressPoints = new[]
                    {
                        "grid_1"
                    };

                var result = CommandExecutor.ExecuteCommand(new GetLocatorsForAddressCommand(address, new GeocodeOptions
                    {
                        AcceptScore = 70,
                        JsonFormat = JsonFormat.None,
                        Locators = LocatorType.All,
                        SuggestCount = 0,
                        WkId = 26912
                    }));

                Assert.That(result.Count, Is.EqualTo(6));
                Assert.That(result.Select(x => x.Url), Is.EquivalentTo(new[]
                    {
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=532+East+400+South&City=grid_1&outSR=26912",
                         "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=400+South+532+East&City=grid_1&outSR=26912",
                        "http://localhost/ArcGIS/rest/services/Geolocators/AddressPoints_AddressSystem/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=400+South+532+East&City=grid_1&outSR=26912",
                        "http://localhost/ArcGIS/rest/services/Geolocators/AddressPoints_AddressSystem/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=532+East+400+South&City=grid_1&outSR=26912",
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=532+East+400+South&City=grid_1&outSR=26912",
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=400+South+532+East&City=grid_1&outSR=26912"
                    }));
            }
            public void GetWordIndex_findsPatternInWord_AndReturnsTheWordIndex()
            {
                //arrange
                const string words = "My house number is 23";
                var service = new ParseAddressCommand();

                //act
                var firstWord = service.GetWordIndex(1, words);
                var secondWord = service.GetWordIndex(5, words);
                var thirdWord = service.GetWordIndex(15, words);
                var fourthWord = service.GetWordIndex(17, words);
                var fifthWord = service.GetWordIndex(21, words);
                var notFound = service.GetWordIndex(45, words);

                //assert
                Assert.AreEqual(firstWord, 0, "first word");
                Assert.AreEqual(secondWord, 1, "2nd");
                Assert.AreEqual(thirdWord, 2, "3rd");
                Assert.AreEqual(fourthWord, 3, "4th");
                Assert.AreEqual(fifthWord, 4, "5th");
                Assert.AreEqual(notFound, -1, "not found");
            }
 public void Setup()
 {
     _parseAddressCommand = new ParseAddressCommand();
 }
            public void GetsLocatorsForAllGrids()
            {
                var command = new ParseAddressCommand("326 east south temple");
                command.Run();

                var parsedAddress = command.Result;

                var command2 = new ParseZoneCommand("84111", new GeocodeAddress(parsedAddress));
                command2.Run();

                var address = command2.Result;

                address.AddressGrids = new List<GridLinkable>
                    {
                        new ZipGridLink(84111, "grid_1", 0),
                        new ZipGridLink(84111, "grid_2", 1)
                    };

                App.GridsWithAddressPoints = new string[] {};

                var result = CommandExecutor.ExecuteCommand(new GetLocatorsForAddressCommand(address, new GeocodeOptions
                    {
                        AcceptScore = 70,
                        JsonFormat = JsonFormat.None,
                        Locators = LocatorType.All,
                        SuggestCount = 0,
                        WkId = 26912
                    }));

                Assert.That(result.Count, Is.EqualTo(8));
                Assert.That(result.Select(x => x.Url), Is.EquivalentTo(new[]
                    {
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                        ,
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                        ,
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS1/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                        ,
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS2/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_1&outSR=26912"
                        ,
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                        ,
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                        ,
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS1/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                        ,
                        "http://localhost/ArcGIS/rest/services/Geolocators/Roads_AddressSystem_ALIAS2/" +
                        "GeocodeServer/findAddressCandidates?f=json&Street=326+east+south+temple&City=grid_2&outSR=26912"
                    }).IgnoreCase);
            }