Пример #1
0
        public void RelocationTestsInitialize()
        {
            var australia = _locationQuery.GetCountry("Australia");

            _tasmania = new LocationReference(_locationQuery.GetCountrySubdivision(australia, "TAS"));
            _armadale = new LocationReference(_locationQuery.GetPostalCode(australia, "3143"));
            _malvern  = new LocationReference(_locationQuery.GetPostalSuburb(_locationQuery.GetPostalCode(australia, "3144"), "Malvern"));
        }
Пример #2
0
        public void TestSimpleSearch()
        {
            // Title only

            var criteria = new JobAdSearchCriteria {
                AdTitle = "ONE"
            };

            TestSearch(criteria, _one);

            // Title and content

            criteria = new JobAdSearchCriteria {
                AdTitle = "title", SortCriteria = new JobAdSearchSortCriteria {
                    SortOrder = JobAdSortOrder.CreatedTime
                }
            };
            criteria.SetKeywords("content");
            TestSearch(criteria, _two, _one);

            // Content and Locality

            GeographicalArea area = _locationQuery.GetPostalCode(_australia, "3143").Locality;

            criteria = new JobAdSearchCriteria {
                Location = new LocationReference(area)
            };
            criteria.SetKeywords("ad AND content");
            TestSearch(criteria, _one);

            // State

            area     = _locationQuery.GetCountrySubdivision(_australia, "NSW");
            criteria = new JobAdSearchCriteria {
                Location = new LocationReference(area)
            };
            TestSearch(criteria, _two);

            // No results

            criteria = new JobAdSearchCriteria {
                AdTitle = "one"
            };
            criteria.SetKeywords("second");
            TestSearch(criteria);
        }
Пример #3
0
        private static LocationReference Map(string location, string postcode, ILocationQuery locationQuery)
        {
            // Need to consolidate location and postcode into a single JobLocation.

            location = (location ?? string.Empty).Trim();
            postcode = (postcode ?? string.Empty).Trim();
            if (postcode.Length != 0)
            {
                // If the postcode is not already part of the location then add it in, but only if it is actually recognised as a postcode.

                if (location.IndexOf(postcode, StringComparison.InvariantCultureIgnoreCase) == -1)
                {
                    var postalCode = locationQuery.GetPostalCode(locationQuery.GetCountry("Australia"), postcode);
                    if (postalCode != null)
                    {
                        location += " " + postcode;
                    }
                }
            }

            // Resolve the location.

            return(locationQuery.ResolveLocation(locationQuery.GetCountry("Australia"), location));
        }
Пример #4
0
        protected void OnLocationLoaded(SearchCriteria criteria)
        {
            var criteriaLocation = criteria as ISearchCriteriaLocation;

            if (criteriaLocation == null)
            {
                return;
            }

            // "255" is reserved for "anywhere"

            if (criteriaLocation.CountryId == 255)
            {
                return;
            }

            // Old alerts store location in different ways so try to use them.

            if (criteriaLocation.Area != null)
            {
                var area = _locationQuery.GetGeographicalArea(criteriaLocation.Area.Value, true);
                criteriaLocation.Location = new LocationReference(area);
                return;
            }

            // Country, default to Australia if not found.

            var country = criteriaLocation.CountryId != null
                ? _locationQuery.GetCountry(criteriaLocation.CountryId.Value)
                : null;

            var postcode = criteriaLocation.Postcode;
            var state    = criteriaLocation.State;
            var location = criteriaLocation.LocationText;

            if (!string.IsNullOrEmpty(postcode))
            {
                // If only the postcode is set then use that.

                if (string.IsNullOrEmpty(state) && string.IsNullOrEmpty(location))
                {
                    var postalCode = _locationQuery.GetPostalCode(country ?? _locationQuery.GetCountry("Australia"), criteriaLocation.Postcode);
                    if (postalCode != null)
                    {
                        criteriaLocation.Location = new LocationReference(postalCode.Locality);
                        return;
                    }
                }
            }

            if (!string.IsNullOrEmpty(criteriaLocation.State))
            {
                // If only the state is set then use that.

                if (string.IsNullOrEmpty(postcode) && string.IsNullOrEmpty(location))
                {
                    var countrySubdivision = _locationQuery.GetCountrySubdivision(country ?? _locationQuery.GetCountry("Australia"), criteriaLocation.State);
                    if (countrySubdivision != null)
                    {
                        criteriaLocation.Location = new LocationReference(countrySubdivision);
                        return;
                    }
                }
            }

            // Standard way.

            if (country == null && string.IsNullOrEmpty(postcode) && string.IsNullOrEmpty(state) && string.IsNullOrEmpty(location))
            {
                return;
            }

            // Put in everything.

            if (string.IsNullOrEmpty(location))
            {
                location = string.Empty;
            }
            if (!string.IsNullOrEmpty(postcode))
            {
                location += " " + postcode;
            }
            if (!string.IsNullOrEmpty(state))
            {
                location += " " + state;
            }

            criteriaLocation.Location = _locationQuery.ResolveLocation(country ?? _locationQuery.GetCountry("Australia"), location);
        }
Пример #5
0
        public static void ClassInitialize(TestContext context)
        {
            _indexWriter = new IndexWriter(new RAMDirectory(), new SimpleAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);

            _australia     = LocationQuery.GetCountry("Australia");
            _victoria      = new LocationReference(LocationQuery.GetCountrySubdivision(_australia, "VIC"));
            _tasmania      = new LocationReference(LocationQuery.GetCountrySubdivision(_australia, "TAS"));
            _queensland    = new LocationReference(LocationQuery.GetCountrySubdivision(_australia, "QLD"));
            _devonport     = new LocationReference(LocationQuery.GetPostalCode(_australia, "7310").Locality);
            _hobart        = new LocationReference(LocationQuery.GetRegion(_australia, "Hobart"));
            _melbourne     = new LocationReference(LocationQuery.GetRegion(_australia, "Melbourne"));
            _goldCoast     = new LocationReference(LocationQuery.GetRegion(_australia, "Gold Coast"));
            _nearGoldCoast = new LocationReference(LocationQuery.GetPostalCode(_australia, "4227").Locality);
            _armadale      = new LocationReference(LocationQuery.GetPostalCode(_australia, "3143"));
            _malvern       = new LocationReference(LocationQuery.GetPostalSuburb(LocationQuery.GetPostalCode(_australia, "3144"), "Malvern"));
            _nearArmadale  = new LocationReference(LocationQuery.GetPostalCode(_australia, "3181").Locality);

            _indexer = new Indexer(new MemberSearchBooster(), LocationQuery, Resolve <IIndustriesQuery>(), null);

            // Zero - not willing to relocate.
            _zero = Guid.NewGuid();
            IndexContent(new MemberContent
            {
                Member = new Member {
                    Id = _zero, Address = new Address {
                        Location = ResolvePostalSuburb("Malvern VIC")
                    }
                },
                Candidate = new Candidate(),
            });

            // One - in NSW, but willing to relocate to Armadale or Malvern or TAS
            _one = Guid.NewGuid();
            IndexContent(new MemberContent
            {
                Member = new Member {
                    Id = _one, Address = new Address {
                        Location = ResolvePostalSuburb("Woolloomooloo NSW"),
                    }
                },
                Candidate = new Candidate {
                    RelocationPreference = RelocationPreference.Yes, RelocationLocations = new[] { _armadale, _malvern, _tasmania }
                },
            });

            // Three - would consider relocating anywhere in Australia
            _three = Guid.NewGuid();
            IndexContent(new MemberContent
            {
                Member = new Member {
                    Id = _three, Address = new Address {
                        Location = ResolvePostalSuburb("Caulfield VIC"),
                    }
                },
                Candidate = new Candidate {
                    RelocationPreference = RelocationPreference.Yes, RelocationLocations = new[] { new LocationReference(LocationQuery.GetCountrySubdivision(_australia, null)) }
                },
            });

            // Four - "would consider" relocating to Gold Coast (region)
            _four = Guid.NewGuid();
            IndexContent(new MemberContent
            {
                Member = new Member {
                    Id = _four, Address = new Address {
                        Location = ResolvePostalSuburb("VIC"),
                    }
                },
                Candidate = new Candidate {
                    RelocationPreference = RelocationPreference.Yes, RelocationLocations = new[] { _goldCoast }
                },
            });

            _indexSearcher = new IndexSearcher(_indexWriter.getReader());
        }