-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(csharp): add client CTS (#2551)
- Loading branch information
1 parent
3316753
commit a6d6ecd
Showing
13 changed files
with
141 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{^autoCreateClient}}var client = {{/autoCreateClient}}new {{client}}(new {{clientPrefix}}Config("{{parametersWithDataTypeMap.appId.value}}","{{parametersWithDataTypeMap.apiKey.value}}"{{#hasRegionalHost}}{{#parametersWithDataTypeMap.region}},"{{parametersWithDataTypeMap.region.value}}"{{/parametersWithDataTypeMap.region}}{{/hasRegionalHost}}), _echo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
await client.{{#lambda.pascalcase}}{{#path}}.{{.}}{{/path}}{{/lambda.pascalcase}}Async{{#isGeneric}}<Object>{{/isGeneric}}({{#parametersWithDataType}}{{> tests/generateParams}}{{^-last}},{{/-last}}{{/parametersWithDataType}}{{#hasRequestOptions}}, new RequestOptions(){ | ||
{{#requestOptions.queryParameters.parametersWithDataType}} | ||
QueryParameters = new Dictionary<string, object>(){ {"{{{key}}}", {{> tests/requests/requestOptionsParams}} }}, | ||
{{/requestOptions.queryParameters.parametersWithDataType}} | ||
{{#requestOptions.headers.parametersWithDataType}} | ||
Headers = new Dictionary<string, string>(){ {"{{{key}}}", "{{{value}}}" }}, | ||
{{/requestOptions.headers.parametersWithDataType}} | ||
}{{/hasRequestOptions}}); | ||
EchoResponse result = _echo.LastResponse; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{#isCreateClient}} | ||
{{> tests/client/createClient}} | ||
{{/isCreateClient}} | ||
{{#isMethod}} | ||
{{> tests/client/method}} | ||
{{/isMethod}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Algolia.Search.Clients; | ||
using Algolia.Search.Models.{{clientPrefix}}; | ||
using Algolia.Search.Http; | ||
using System.Text.RegularExpressions; | ||
using Xunit; | ||
|
||
public class {{client}}Tests | ||
{ | ||
private readonly EchoHttpRequester _echo; | ||
private Exception _ex; | ||
public {{client}}Tests() | ||
{ | ||
_echo = new EchoHttpRequester(); | ||
} | ||
|
||
[Fact] | ||
public void Dispose() | ||
{ | ||
} | ||
|
||
{{#blocksClient}} | ||
{{#tests}} | ||
[Fact(DisplayName = "{{{testName}}}")] | ||
public async Task {{#lambda.pascalcase}}{{testType}}Test{{testIndex}}{{/lambda.pascalcase}}() | ||
{ | ||
{{#autoCreateClient}} | ||
var client = new {{client}}(new {{clientPrefix}}Config("appId", "apiKey"{{#hasRegionalHost}},"{{defaultRegion}}"{{/hasRegionalHost}}), _echo); | ||
{{/autoCreateClient}} | ||
{{#steps}} | ||
{{#isError}} | ||
_ex = await Assert.ThrowsAnyAsync<Exception>(async () => { {{> tests/client/step}} }); | ||
Assert.Equal("{{{expectedError}}}".ToLowerInvariant(), _ex.Message.ToLowerInvariant()); | ||
|
||
{{/isError}} | ||
{{^isError}} | ||
{{> tests/client/step}} | ||
{{#match}} | ||
{{#testUserAgent}} { | ||
var regexp = new Regex("{{#lambda.escapeSlash}}{{{match}}}{{/lambda.escapeSlash}}"); | ||
Assert.Matches(regexp,result.Headers["user-agent"]); | ||
}{{/testUserAgent}} | ||
{{#testTimeouts}} | ||
Assert.Equal({{{match.parametersWithDataTypeMap.connectTimeout.value}}}, result.ConnectTimeout.TotalMilliseconds); | ||
Assert.Equal({{{match.parametersWithDataTypeMap.responseTimeout.value}}}, result.ResponseTimeout.TotalMilliseconds); | ||
{{/testTimeouts}} | ||
{{#testHost}} | ||
Assert.Equal("{{{match}}}", result.Host); | ||
{{/testHost}} | ||
{{/match}} | ||
{{/isError}} | ||
{{/steps}} | ||
} | ||
{{/tests}} | ||
{{/blocksClient}} | ||
} |