Skip to content

Commit 87e7b47

Browse files
committed
use copilot to write manual tests
1 parent aee233f commit 87e7b47

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

samples/client/petstore/csharp/generichost/net8/ManualPetstoreTests/OpenAPIClient-generichost-manual-tests/MultipartContentTypeTests.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,19 @@ await petApi.UploadFilesAsync(
151151
$"but found {parts.Length - 1}. Body:\n{_capturingHandler.CapturedBody}");
152152
}
153153

154+
/// <summary>
155+
/// Covers issue #21384: multipart/form-data with only text form fields (no file)
156+
/// must still include the boundary in Content-Type so the server can parse the body.
157+
/// Uses UploadFileAsync with only the optional additionalMetadata text field, no file.
158+
/// </summary>
154159
[TestMethod]
155-
public async Task UpdatePetWithForm_FormFieldsOnly_ContentTypeHasBoundary()
160+
public async Task UploadFile_TextFieldOnly_NoFile_ContentTypeHasBoundary()
156161
{
157162
var petApi = _host.Services.GetRequiredService<IPetApi>();
158163

159-
await petApi.UpdatePetWithFormAsync(
164+
await petApi.UploadFileAsync(
160165
petId: 1,
161-
name: new Option<string>("Fido"),
162-
status: new Option<string>("available"));
166+
additionalMetadata: new Option<string>("some metadata"));
163167

164168
Assert.IsNotNull(_capturingHandler.CapturedContentType,
165169
"Content-Type header should not be null for a multipart/form-data request.");
@@ -170,20 +174,17 @@ await petApi.UpdatePetWithFormAsync(
170174
}
171175

172176
[TestMethod]
173-
public async Task UpdatePetWithForm_FormFieldsOnly_BodyContainsFormValues()
177+
public async Task UploadFile_TextFieldOnly_NoFile_BodyContainsTextValue()
174178
{
175179
var petApi = _host.Services.GetRequiredService<IPetApi>();
176180

177-
await petApi.UpdatePetWithFormAsync(
181+
await petApi.UploadFileAsync(
178182
petId: 1,
179-
name: new Option<string>("Fido"),
180-
status: new Option<string>("available"));
183+
additionalMetadata: new Option<string>("testmetadata"));
181184

182185
Assert.IsNotNull(_capturingHandler.CapturedBody, "Body should not be null.");
183-
StringAssert.Contains(_capturingHandler.CapturedBody, "Fido",
184-
"Body should contain the name value.");
185-
StringAssert.Contains(_capturingHandler.CapturedBody, "available",
186-
"Body should contain the status value.");
186+
StringAssert.Contains(_capturingHandler.CapturedBody, "testmetadata",
187+
"Body should contain the additionalMetadata value.");
187188
}
188189
}
189190
}

0 commit comments

Comments
 (0)