test: cover BlogApiClient.CreateMultipartContent shape + server round-trip

Expose CreateMultipartContent as public so the blogs backend tests can
assert on its wire shape directly and round-trip it through the live
BlogsWebServerFixture host. New CreateMultipartContentTests:
- shape: blog part is camelCase JSON with WhenWritingNull, one file
  part per attachment (filename, Content-Type, octet-stream fallback);
- round-trip: POST the built body to /api/v1/blogspot, assert 201
  Created + attachment row + file landed under BlogFilesRoot.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Paul Schneider 2026-09-18 11:39:45 +01:00
commit ac1ba2ee68
Signed by: notazof
GPG key ID: 1DD5D838E5343B06
2 changed files with 267 additions and 1 deletions

View file

@ -99,7 +99,18 @@ public sealed class BlogApiClient
return await _api.CallAsync<BlogPostDto?>(method, path, () => CreateMultipartContent(post, files), ct: ct);
}
private static HttpContent CreateMultipartContent(BlogPostDto post, IReadOnlyCollection<BlogUploadFile> files)
/// <summary>Build the <c>multipart/form-data</c> body PostIt
/// sends when a blog post is saved with one or more
/// attachments: a <c>blog</c> field holding the
/// <paramref name="post"/> serialised camelCase with
/// <c>WhenWritingNull</c>, plus one <c>file</c> part per entry
/// in <paramref name="files"/> (each carrying its
/// <see cref="BlogUploadFile.ContentType"/>, falling back to
/// <c>application/octet-stream</c> when unset). Exposed as
/// <c>public</c> so the blogs backend tests can assert on the
/// wire shape directly and round-trip it through the live
/// <c>BlogsWebServerFixture</c> host.</summary>
public static HttpContent CreateMultipartContent(BlogPostDto post, IReadOnlyCollection<BlogUploadFile> files)
{
var content = new MultipartFormDataContent();
var blogJson = JsonSerializer.Serialize(post, new JsonSerializerOptions