-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMatchV2Tests.cs
More file actions
161 lines (138 loc) · 5.53 KB
/
MatchV2Tests.cs
File metadata and controls
161 lines (138 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Textkernel.Tx.Models.API.Matching.Request;
using Textkernel.Tx.Models.API.Matching;
using Textkernel.Tx.Models.Matching;
using Textkernel.Tx.Models.API.MatchV2.Request;
using Textkernel.Tx.Models.API.Parsing;
using Textkernel.Tx.Models;
using System.Collections;
namespace Textkernel.Tx.SDK.Tests.IntegrationTests
{
public class MatchV2Tests : TestBase
{
private readonly string _documentId = Guid.NewGuid().ToString();
[OneTimeSetUp]
public async Task SetupAIMatchingIndexes()
{
// add a document to each index
await Client.SearchMatchV2.AddJob(_documentId, TestParsedJobTech);
await Client.SearchMatchV2.AddCandidate(_documentId, TestParsedResume);
await DelayForIndexSync(5_000);
}
[OneTimeTearDown]
public async Task TeardownMatchingIndexes()
{
await Client.SearchMatchV2.DeleteJobs([_documentId]);
await Client.SearchMatchV2.DeleteCandidates([_documentId]);
await DelayForIndexSync(5_000);
}
[TestCase("Developer")]
[TestCase("VB6")]
public async Task TestSearch(string validSearchTerm)
{
Assert.ThrowsAsync<TxException>(async () =>
{
await Client.SearchMatchV2.SearchCandidates(null, null);
});
SearchQuery query = new SearchQuery();
Assert.ThrowsAsync<TxException>(async () =>
{
await Client.SearchMatchV2.SearchCandidates(query, null);
});
Options opts = new Options();
query.QueryString = validSearchTerm;
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.SearchCandidates(query, opts).Result.Value;
Assert.IsNotEmpty(response.ResultItems);
});
query.QueryString = "ThisIsATermThatIsntInTheDocument";
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.SearchCandidates(query, opts).Result.Value;
Assert.AreEqual(0, response.MatchSize);
});
await Task.CompletedTask;
}
[Test]
public async Task TestParseAndUpload()
{
Document document = GetTestFileAsDocument("resume.docx");
string docId = Guid.NewGuid().ToString();
var options = new ParseOptions()
{
ProfessionsSettings = new ProfessionsSettings()
{
Normalize = false
},
IndexingOptions = new Models.API.Indexes.IndexingOptionsGeneric()
{
SearchAndMatchVersion = Models.API.Indexes.SearchAndMatchVersion.V2,
DocumentId = docId
}
};
ParseResumeResponse response = await Client.Parser.ParseResume(new ParseRequest(document, options));
Assert.True(response.Value.IndexingResponse.IsSuccess);
await DelayForIndexSync(10_000);
Options opts = new Options();
SearchQuery query = new SearchQuery();
query.QueryString = "Developer";
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.SearchCandidates(query, opts).Result.Value;
Assert.IsNotEmpty(response.ResultItems);
Assert.IsNotEmpty(response.ResultItems.Where(i => i.DocID == docId));
});
await Client.SearchMatchV2.DeleteCandidates([docId]);
await DelayForIndexSync(5_000);
}
//[Test]
public async Task TestMatch()
{
Assert.ThrowsAsync<TxException>(async () =>
{
await Client.SearchMatchV2.MatchJobs(null, null);
});
Options opts = new Options();
Assert.ThrowsAsync<TxException>(async () =>
{
await Client.SearchMatchV2.MatchJobs(null, opts);
});
Assert.ThrowsAsync<TxException>(async () =>
{
await Client.SearchMatchV2.MatchJobs(new DocumentSource { Id = "fake-doc-id" }, opts);
});
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.MatchJobs(new DocumentSource { Id = _documentId, Type = DocumentType.vacancy }, opts).Result.Value;
Assert.IsNotEmpty(response.ResultItems);
});
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.MatchCandidates(new DocumentSource { Id = _documentId, Type = DocumentType.vacancy }, opts).Result.Value;
Assert.IsNotEmpty(response.ResultItems);
});
await Task.CompletedTask;
}
[Test]
public async Task TestAutocomplete()
{
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.AutocompleteCandidates(AutocompleteCandidatesField.AllJobTitles, "Softwa").Result;
Assert.IsNotEmpty(response.Value.Return);
});
Assert.DoesNotThrow(() =>
{
var response = Client.SearchMatchV2.AutocompleteJobs(AutocompleteJobsField.Location, "York").Result;
Assert.IsNotEmpty(response.Value.Return);
});
await Task.CompletedTask;
}
}
}