Ejemplo n.º 1
0
            public async Task Should_remove_candidates_below_accept_score()
            {
                var candidates = new[] {
                    new Candidate {
                        Address     = "winner",
                        Score       = 1,
                        AddressGrid = "grid",
                        Location    = new Point(0, 0)
                    },
                    new Candidate {
                        Address     = "remove",
                        Score       = 0,
                        AddressGrid = "grid",
                        Location    = new Point(1, 1)
                    }
                };

                var options = new GeocodingOptions {
                    AcceptScore = 1,
                    Suggest     = 1
                };

                var address = new GeocodeAddress(new CleansedAddress())
                {
                    AddressGrids = new[] { new ZipGridLink(0, "grid", 0) }
                };

                var request = new FilterCandidates.Command(candidates, options, "street", "zone", address);
                var result  = await Handler.Handle(request, CancellationToken.None);

                result.Candidates.ShouldBeEmpty();
                result.MatchAddress.ShouldBe("winner");
            }
Ejemplo n.º 2
0
            public async Task Should_calculate_score_difference()
            {
                var candidates = new[] {
                    new Candidate {
                        Address     = "winner",
                        Score       = 10,
                        AddressGrid = "grid",
                        Location    = new Point(0, 0)
                    },
                    new Candidate {
                        Address     = "suggest",
                        Score       = 1,
                        AddressGrid = "grid",
                        Location    = new Point(1, 1)
                    }
                };

                var options = new GeocodingOptions {
                    AcceptScore     = 1,
                    ScoreDifference = true
                };

                var address = new GeocodeAddress(new CleansedAddress())
                {
                    AddressGrids = new[] { new ZipGridLink(0, "grid", 0) }
                };

                var request = new FilterCandidates.Command(candidates, options, "street", "zone", address);
                var result  = await Handler.Handle(request, CancellationToken.None);

                result.Candidates.ShouldBeEmpty();
                result.ScoreDifference.ShouldBe(9);
            }
Ejemplo n.º 3
0
            public async Task Should_return_default_empty_response_when_null_candidates()
            {
                var request = new FilterCandidates.Command(null, null, "street", "zone", null);
                var result  = await Handler.Handle(request, CancellationToken.None);

                result.InputAddress.ShouldBe($"street, zone");
                result.Score.ShouldBe(-1);
            }