dennisdoomen / dennisdoomen/fluentassertions.mockly

[API Proposal]: Add cookie and multipart form-file assertions

Open
#81 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Motivation

`WithFormField(name, valuePattern)` covers `application/x-www-form-urlencoded` bodies. Two common request shapes have no assertion support:

- **Cookies.** Session and anti-forgery cookies are part of plenty of API interactions, and asserting on them today means digging through the raw `Cookie` header by hand.
- **Multipart file uploads.** `multipart/form-data` is the standard way to upload a file, and there is currently no way to assert which part carried which file, or what its content type was.

## Proposed API

```csharp
requests.Should().ContainRequestFor("/api/session")
.WithCookie("session-id")
.WithCookie("tenant", "acme");

requests.Should().ContainRequestFor("/api/avatar")
.WithFormFile("avatar", "portrait.png")
.WithFormFile("avatar", fileName: "*.png", contentType: "image/png");
```

## Notes

- Cookie assertions only need the request headers, so they are self-contained.
- Multipart parsing is the harder half. It may be better to land it in the core library first (as a `WithFormFile` *matcher*, mirroring how `WithFormField` matching preceded the assertion) so both sides share one parser rather than each writing their own.
- Worth splitting into two issues if the multipart half turns out to be significantly more work.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the existing WithFormField assertion and its matcher or core implementation. Trace how request headers are exposed for cookie checks and determine where multipart parsing belongs; done means cookie and multipart file assertions support the examples, including filename and content-type matching, with the work split if needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.