Skip to content

Draft: TUnit Example#4065

Draft
thomhurst wants to merge 5 commits into
BrighterCommand:masterfrom
thomhurst:feature/tunit-migration
Draft

Draft: TUnit Example#4065
thomhurst wants to merge 5 commits into
BrighterCommand:masterfrom
thomhurst:feature/tunit-migration

Conversation

@thomhurst

Copy link
Copy Markdown
Contributor

You mentioned last week that you wondered if TUnit was worth switching to - So thought I'd just do a draft branch to show you what Brighter would look like switched over.

Might be useful to see if test speeds improve or anything. I attempted to enable parallelisation by having tests use unique topic names, or queue names, etc. to better support test isolation. (Though I don't know if limited CI constraints will fight against more parallelisation!)

Don't feel obliged to adopt it or anything, just thought it'd be a bit more useful to see it in something more tangible.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@iancooper

Copy link
Copy Markdown
Member

Oh, thanks for this. It's certainly more concrete. I need to let @lillo42 finish his generated tests, because it's hard to hit a moving target, but we could certainly think about this after that.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@thomhurst
thomhurst force-pushed the feature/tunit-migration branch from 635350a to c76d53c Compare April 15, 2026 19:52
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@thomhurst

Copy link
Copy Markdown
Contributor Author

@iancooper — question about CompressPayloadTransformer sync vs async divergence I ran into while fixing the Core.Tests CI failures on this branch.

WrapAsync sets CharSet on the compressed ContentType (from the source message's charset, falling back to utf-8):

contentType.CharSet = message.Header.ContentType?.CharSet ?? CharacterEncoding.UTF8.FromCharacterEncoding();

Sync Wrap in the same file does not set CharSet. The two paths produce different headers for the same input.

The compressed payload is binary (stored as CharacterEncoding.Raw), and application/gzip / application/deflate / application/br have no registered charset parameter per IANA, so attaching one to the compressed ContentType looks semantically wrong. The original content type (with charset) is already preserved in ORIGINAL_CONTENTTYPE_HEADER for the unwrap side.

This was invisible until commit c76d53c switched a sync-origin test from WrapWrapAsync, exposing the mismatch (the existing CompressLargePayloadTests assertions expected no charset; the separate AsyncCompressLargePayloadTests was written against the async-with-charset behaviour). My fix removed the charset line in WrapAsync to match Wrap, and updated the duplicate async test file accordingly.

Two reasonable directions here — which do you want?

  1. Keep my change: sync and async both omit charset on the compressed ContentType (what's on the branch now). Semantically correct per IANA, but a behaviour change for consumers relying on the current async output.
  2. Revert and do the opposite: update sync Wrap to also set CharSet. Preserves existing async output, but bakes in the meaningless-charset-on-binary behaviour in both paths.

Happy to flip to (2) if you'd rather preserve the existing on-the-wire format.

@thomhurst
thomhurst force-pushed the feature/tunit-migration branch from 0cd2522 to 26f2436 Compare April 24, 2026 00:29
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@thomhurst

Copy link
Copy Markdown
Contributor Author

Also noticed that emitted spans may have incorrect durations:
image

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@thomhurst
thomhurst force-pushed the feature/tunit-migration branch from f3d83ea to 55b449d Compare April 26, 2026 20:54
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@thomhurst
thomhurst force-pushed the feature/tunit-migration branch from 8de8938 to 48560b0 Compare April 29, 2026 19:22
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@thomhurst
thomhurst force-pushed the feature/tunit-migration branch from ae913fc to 79f36bf Compare May 6, 2026 19:54
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Health Improved (1 files improve in Code Health)

Gates Failed
Prevent hotspot decline (1 hotspot with Low Cohesion)
Enforce critical code health rules (1 file with Low Cohesion)
Enforce advisory code health rules (1 file with Code Duplication)

Gates Passed
1 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Prevent hotspot decline Violations Code Health Impact
RedisMessageConsumer.cs 1 rule in this hotspot 6.72 → 6.33 Suppress
Enforce critical code health rules Violations Code Health Impact
RedisMessageConsumer.cs 1 critical rule 6.72 → 6.33 Suppress
Enforce advisory code health rules Violations Code Health Impact
CompressPayloadTransformer.cs 1 advisory rule 8.82 → 8.55 Suppress
View Improvements
File Code Health Impact Categories Improved
RedisMessageProducer.cs 9.39 → 10.00 Code Duplication

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@thomhurst
thomhurst force-pushed the feature/tunit-migration branch from e1102c7 to 5d3ba07 Compare July 17, 2026 18:52
Use ordered collection equivalence instead of reference equality.
Restore the omitted CloudEvents content-type argument.
Use unique closed generic types per scenario so tests exercise public pipeline behavior without clearing or inspecting shared caches.
Use unique routing keys and dispose trace providers so each test observes only spans emitted by its own message flow.
Use value-based collection assertions and isolate the PostgreSQL test that controls the public migration history table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants