public void TestInitialize() { _australia = _locationQuery.GetCountry("Australia"); Resolve <IDbConnectionFactory>().DeleteAllTestData(); JobAdSearchHost.ClearIndex(); var employer = _employerAccountsCommand.CreateTestEmployer("jobposter", _organisationsCommand.CreateTestOrganisation("The Job Advertiser")); _one = employer.CreateTestJobAd("Title one", "The content for the first ad"); _one.CreatedTime = DateTime.Now.AddDays(-1); // Just to make sure it's before "two"; we only index days. _one.Description.Salary = new Salary { LowerBound = 50000, UpperBound = 60000, Rate = SalaryRate.Year, Currency = Currency.AUD }; _jobAdsCommand.CreateJobAd(_one); _jobAdsCommand.OpenJobAd(_one); _two = employer.CreateTestJobAd("Title two", "Different content for the second ad"); _locationQuery.ResolvePostalSuburb(_two.Description.Location, _australia, "2000"); _two.Description.CompanyName = "Really Bad Employers"; _two.Description.JobTypes = JobTypes.Contract; _two.Description.Industries = new List <Industry> { _industriesQuery.GetIndustry("Other") }; _jobAdsCommand.CreateJobAd(_two); _jobAdsCommand.OpenJobAd(_two); }
public void TestSimpleSort() { _australia = _locationQuery.GetCountry("Australia"); var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0)); var one = employer.CreateTestJobAd("Title one", "The content for the first ad"); one.CreatedTime = DateTime.Now.AddDays(-1); // Just to make sure it's before "two"; we only index days. one.Description.Salary = new Salary { LowerBound = 50000, UpperBound = 60000, Rate = SalaryRate.Year, Currency = Currency.AUD }; _jobAdsCommand.CreateJobAd(one); _jobAdsCommand.OpenJobAd(one); var two = employer.CreateTestJobAd("Title two", "Different content for the second ad"); _locationQuery.ResolvePostalSuburb(two.Description.Location, _australia, "2000"); two.Description.CompanyName = "Really Bad Employers"; two.Description.JobTypes = JobTypes.Contract; two.Description.Industries = new List <Industry> { _industriesQuery.GetIndustry("Other") }; _jobAdsCommand.CreateJobAd(two); _jobAdsCommand.OpenJobAd(two); var member = new Member { Id = Guid.NewGuid() }; var flagList = _jobAdFlagListsQuery.GetFlagList(member); _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, one.Id); _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, two.Id); // Title only var criteria = new JobAdSearchSortCriteria { SortOrder = JobAdSortOrder.JobType }; TestSort(member, criteria, one, two); // Title and content criteria = new JobAdSearchSortCriteria { SortOrder = JobAdSortOrder.CreatedTime }; TestSort(member, criteria, two, one); // No results //criteria = new JobAdSortCriteria { AdTitle = "one", Keywords = "second" }; //TestSort(criteria); }
public static Member CreateTestMember(this IMembersCommand membersCommand, string emailAddress, string firstName, string lastName, DateTime?createdTime) { var member = new Member { IsEnabled = true, IsActivated = true, EmailAddresses = new List <EmailAddress> { new EmailAddress { Address = emailAddress, IsVerified = true } }, PhoneNumbers = new List <PhoneNumber> { new PhoneNumber { Number = DefaultPhoneNumber, Type = PhoneNumberType.Mobile } }, FirstName = firstName, LastName = lastName, Gender = DefaultGender, DateOfBirth = DefaultDateOfBirth, VisibilitySettings = new VisibilitySettings(), }; if (createdTime.HasValue) { member.CreatedTime = createdTime.Value; member.LastUpdatedTime = createdTime.Value; } // Deny public access to real name, because existing tests rely on this. Might need to change this later. member.VisibilitySettings.Personal.PublicVisibility &= ~PersonalVisibility.Name; member.Address = new Address { Location = new LocationReference() }; _locationQuery.ResolvePostalSuburb(member.Address.Location, DefaultCountry, DefaultLocation); membersCommand.CreateMember(member); return(member); }
public string ResolvePostalSuburb(int countryId, string location) { try { // If the country is not specified then use the current context. Country country = _locationQuery.GetCountry(countryId); if (country == null) { country = /*RequestContext.Current.LocationContext.Country*/ _locationQuery.GetCountry("Australia"); } // Try to resolve. var locationReference = _locationQuery.ResolvePostalSuburb(country, location); if (locationReference.IsFullyResolved) { // Fully resolved. At least as resolved as it is going to get, // for those countries which don't actually have suburbs defined // this will indicate it is resolved but there won't actually be a postal suburb set. if (locationReference.PostalSuburb != null) { return(Resolve(country, locationReference.PostalSuburb, location)); } else { return(location); } } else { return(string.Empty); } } catch (Exception) { return(string.Empty); } }
public static void UpdateMemberAddress(Member member, Country newCountry, string newLocation) { _locationQuery.ResolvePostalSuburb(member.Address.Location, newCountry, newLocation); }
private static LocationReference ResolvePostalSuburb(string location) { return(LocationQuery.ResolvePostalSuburb(_australia, location)); }
private static Member CreateTestMember(this IMemberAccountsCommand memberAccountsCommand, bool createKnownInvalidMember, string emailAddress, string password, string firstName, string lastName, bool activated, Guid?affiliateId, DateTime?createTime, LocationReference location) { var member = new Member { EmailAddresses = new List <EmailAddress> { new EmailAddress { Address = emailAddress, IsVerified = true } }, IsActivated = activated, IsEnabled = true, PhoneNumbers = new List <PhoneNumber> { new PhoneNumber { Number = DefaultPhoneNumber, Type = PhoneNumberType.Mobile } }, FirstName = firstName, LastName = lastName, Gender = DefaultGender, DateOfBirth = DefaultDateOfBirth, }; if (createTime.HasValue) { member.CreatedTime = createTime.Value; } var credentials = new LoginCredentials { LoginId = emailAddress, PasswordHash = LoginCredentials.HashToString(password) }; // Deny public access to real name, because existing tests rely on this. Might need to change this later. member.VisibilitySettings = new VisibilitySettings(); member.VisibilitySettings.Personal.PublicVisibility &= ~PersonalVisibility.Name; if (location == null) { member.Address = new Address { Location = new LocationReference() }; LocationQuery.ResolvePostalSuburb(member.Address.Location, DefaultCountry, DefaultLocation); } else { member.Address = new Address { Location = location }; } if (createKnownInvalidMember) { CreateInvalidMember(member, credentials, affiliateId); } else { memberAccountsCommand.CreateMember(member, credentials, affiliateId); } return(member); }