@@ -101,7 +101,7 @@ namespace {{ spec.title | caseUcfirst }}.Tests.Services
101101 {%~ if method .parameters .all | length > 0 %}
102102 var result = await _{{ service .name | caseCamel }}.{{ method .name | caseUcfirst }}(
103103 {%~ for parameter in method .parameters .all | filter((param ) => param .required ) ~%}
104- {{parameter.name | caseCamel | escapeKeyword}}: {% if parameter.enumValues is not empty %}{{ spec.title | caseUcfirst }}.Enums.{{ (parameter.enumName ?? parameter.name) | caseUcfirst }}.{{ (parameter.enumKeys[0] ?? parameter.enumValues[0]) | caseEnumKey }}{% elseif parameter.type == 'file' %}InputFile.FromPath("./test.png"){% elseif parameter.type == 'object' %}new Dictionary<string, object>(){% elseif parameter.type == 'array' %}{% set itemType = test_item_type(parameter) %}new List<{{ itemType }}> { {% if itemType == 'string' %}"item1"{% elseif itemType == 'long' %}1{% elseif itemType == 'double' %}1.0{% elseif itemType == 'bool' %}true{% elseif itemType == 'object' %}new object(){% else %}null{% endif %} }{% elseif parameter.type == 'boolean' %}true{% elseif parameter.type == 'integer' %}{{parameter['x-example'] | default(1)}}{% elseif parameter.type == 'number' %}{{parameter['x-example'] | default(1.0)}}{% elseif parameter.type == 'string' %}"{% if parameter['x-example'] is not empty %}{{parameter['x-example']}}{% else %}test{% endif %}"{% else %}null{% endif %}{% if not loop.last %},{% endif %}
104+ {{parameter.name | caseCamel | escapeKeyword}}: {% if parameter.enumValues is not empty %}{{ spec.title | caseUcfirst }}.Enums.{{ (parameter.enumName ?? parameter.name) | caseUcfirst }}.{{ (parameter.enumKeys[0] ?? parameter.enumValues[0]) | caseEnumKey }}{% elseif parameter.type == 'file' %}InputFile.FromPath("./test.png"){% elseif parameter.type == 'object' %}new Dictionary<string, object>(){% elseif parameter.type == 'array' %}{% set itemType = test_item_type(parameter) %}new List<{{ itemType }}> { {% if itemType == 'string' %}"item1"{% elseif itemType == 'long' %}1{% elseif itemType == 'double' %}1.0{% elseif itemType == 'bool' %}true{% elseif itemType == 'object' %}new object(){% else %}null{% endif %} }{% elseif parameter.type == 'boolean' %}true{% elseif parameter.type == 'integer' %}{{parameter['x-example'] | default(1)}}{% elseif parameter.type == 'number' %}{{parameter['x-example'] | default(1.0)}}{% elseif parameter.type == 'string' %}"{% if parameter['x-example'] is not empty %}{{parameter['x-example'] | escapeCsString}}{% else %}test{% endif %}"{% else %}null{% endif %}{% if not loop.last %},{% endif %}
105105
106106 {%~ endfor ~%}
107107 );
@@ -167,19 +167,38 @@ namespace {{ spec.title | caseUcfirst }}.Tests.Services
167167 };
168168 {%~ elseif method .type == ' location' %}
169169 var expectedResponse = new byte[] { 1, 2, 3 };
170+ {%~ elseif method .type == ' webAuth' %}
171+ var expectedResponse = "success";
170172 {%~ else %}
171173 var expectedResponse = new Dictionary<string , object >();
172174 {%~ endif %}
173175
174- {%~ if not ( method .type == ' webAuth' or ' multipart/form-data ' in method . consumes ) %}
175- _mockClient.Setup(c => c.Call < {{ utils. resultType ( spec . title , method ) }}> (
176+ {%~ if method .type == ' webAuth' %}
177+ _mockClient.Setup(c => c.Redirect (
176178 It.IsAny<string >(),
177179 It.IsAny<string >(),
178180 It.IsAny<Dictionary <string , string >>(),
179- It.IsAny<Dictionary <string , object >>(){% if method .responseModel %},
180- It.IsAny<Func <Dictionary <string , object >, {{ utils.resultType (spec .title , method ) }}>>()
181- {% else %},null{% endif %}
182- )).ReturnsAsync({% if method .responseModel and method .responseModel != ' any' and method .type != ' location' %}{{ spec .title | caseUcfirst }}.Models.{{ method .responseModel | caseUcfirst | overrideIdentifier }}.From(expectedResponse){% else %}expectedResponse{% endif %});
181+ It.IsAny<Dictionary <string , object >>()
182+ )).ReturnsAsync(expectedResponse);
183+ {%~ elseif ' multipart/form-data' in method .consumes %}
184+ _mockClient.Setup(c => c.ChunkedUpload< {{ utils.resultType (spec .title , method ) }}>(
185+ It.IsAny<string >(),
186+ It.IsAny<Dictionary <string , string >>(),
187+ It.IsAny<Dictionary <string , object >>(),
188+ It.IsAny<Func <Dictionary <string , object >, {{ utils.resultType (spec .title , method ) }}>>(),
189+ It.IsAny<string >(),
190+ It.IsAny<string >(),
191+ It.IsAny<Action <UploadProgress >>()
192+ )).ReturnsAsync({% if method .responseModel and method .responseModel != ' any' %}{{ spec .title | caseUcfirst }}.Models.{{ method .responseModel | caseUcfirst | overrideIdentifier }}.From(expectedResponse){% else %}expectedResponse{% endif %});
193+ {%~ else %}
194+ _mockClient.Setup(c => c.Call< {{ utils.resultType (spec .title , method ) }}>(
195+ It.IsAny<string >(),
196+ It.IsAny<string >(),
197+ It.IsAny<Dictionary <string , string >>(),
198+ It.IsAny<Dictionary <string , object >>(){% if method .responseModel %},
199+ It.IsAny<Func <Dictionary <string , object >, {{ utils.resultType (spec .title , method ) }}>>()
200+ {% else %},null{% endif %}
201+ )).ReturnsAsync({% if method .responseModel and method .responseModel != ' any' and method .type != ' location' %}{{ spec .title | caseUcfirst }}.Models.{{ method .responseModel | caseUcfirst | overrideIdentifier }}.From(expectedResponse){% else %}expectedResponse{% endif %});
183202 {%~ endif %}
184203
185204 // Act
0 commit comments