public async Task TestResumeGeocodeIndex() { string indexId = "SDK-resume-" + nameof(TestJobGeocodeIndex); string documentId = "1"; try { await Client.CreateIndex(IndexType.Resume, indexId); // missing indexing options Assert.ThrowsAsync <SovrenException>(async() => { await Client.GeocodeAndIndex(TestParsedResumeWithAddress, null); }); // empty indexing options IndexSingleDocumentInfo indexingOptions = new IndexSingleDocumentInfo(); Assert.ThrowsAsync <SovrenException>(async() => { await Client.GeocodeAndIndex(TestParsedResumeWithAddress, indexingOptions); }); // missing documentid indexingOptions.IndexId = indexId; Assert.ThrowsAsync <SovrenException>(async() => { await Client.GeocodeAndIndex(TestParsedResumeWithAddress, indexingOptions); }); indexingOptions.DocumentId = documentId; // not enough data points to index Assert.ThrowsAsync <SovrenException>(async() => { await Client.GeocodeAndIndex(TestParsedResume, indexingOptions); }); Assert.DoesNotThrowAsync(async() => { await Client.GeocodeAndIndex(TestParsedResumeWithAddress, indexingOptions); }); Assert.DoesNotThrowAsync(async() => { await Client.GetResume(indexId, documentId); }); } finally { await CleanUpIndex(indexId); } await Task.CompletedTask; }
public async Task TestJobGeocodeIndexReplaceAddress() { string indexId = "SDK-job-" + nameof(TestJobGeocodeIndexReplaceAddress); string documentId = "1"; try { await Client.CreateIndex(IndexType.Job, indexId); IndexSingleDocumentInfo indexingOptions = new IndexSingleDocumentInfo { IndexId = indexId, DocumentId = documentId }; GeocodeCredentials geocodeCredentials = new GeocodeCredentials() { Provider = GeocodeProvider.None }; Address address = new Address() { Municipality = "Dallas", Region = "TX", CountryCode = "US", PostalCode = "75214" }; GeocodeAndIndexJobResponse response = await Client.GeocodeAndIndex(TestParsedJobWithAddress, indexingOptions, address, geocodeCredentials); Assert.Multiple(() => { Assert.AreEqual(0m, response.Info.TransactionCost); Assert.AreEqual(address.CountryCode, response.Value.JobData.CurrentLocation.CountryCode); Assert.AreEqual(address.Region, response.Value.JobData.CurrentLocation.Regions.FirstOrDefault()); Assert.AreEqual(address.Municipality, response.Value.JobData.CurrentLocation.Municipality); Assert.AreEqual(address.PostalCode, response.Value.JobData.CurrentLocation.PostalCode); }); Assert.DoesNotThrowAsync(async() => { await Client.GetJob(indexId, documentId); }); SearchResponse searchResponse = await Client.Search(new[] { indexId }, new FilterCriteria() { LocationCriteria = new LocationCriteria() { Locations = new List <FilterLocation>() { new FilterLocation() { CountryCode = address.CountryCode, Municipality = address.Municipality, PostalCode = address.PostalCode, Region = address.Region } } } }); Assert.AreEqual(1, searchResponse.Value.CurrentCount); } finally { await CleanUpIndex(indexId); } await Task.CompletedTask; }