dotnet-hosted-service-testing

dotnet-hosted-service-testing is a skill for Claude Code, Codex from Arasz/ai-raccoon. It costs 84 tokens per session (2,029 once invoked), scanned A, original, MIT.

A testing guide for .NET background services, which are programs that run work in the background at intervals or in response to events. It explains how to test their timers, loops, dependency injection, and error paths with a controllable clock.

In plain words
What is it for?
Use it when writing or reviewing tests for BackgroundService polling, periodic jobs, duplicate prevention, failure handling, or service registration.
Why use it?
Time-based tests can pass without exercising the real loop, especially when work runs on another thread. The guide helps distinguish actual timer invocations from misleading side effects.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing or reviewing tests for BackgroundService polling, periodic jobs, duplicate prevention, failure handling, or service registration.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/arasz/ai-raccoon/dotnet-hosted-service-testing
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Arasz/ai-raccoon --skill dotnet-hosted-service-testing
Clone the repo
git clone --depth 1 https://github.com/Arasz/ai-raccoon

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for dotnet-hosted-service-testing

README.md
[![agentmods](https://agentmods.dev/badge/skills/arasz/ai-raccoon/dotnet-hosted-service-testing/github.svg)](https://agentmods.dev/skills/arasz/ai-raccoon/dotnet-hosted-service-testing)
Your own site
<a href="https://agentmods.dev/skills/arasz/ai-raccoon/dotnet-hosted-service-testing"><img src="https://agentmods.dev/badge/skills/arasz/ai-raccoon/dotnet-hosted-service-testing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dotnet-hosted-service-testing

Your own site · 80×15
<a href="https://agentmods.dev/skills/arasz/ai-raccoon/dotnet-hosted-service-testing"><img src="https://agentmods.dev/badge/skills/arasz/ai-raccoon/dotnet-hosted-service-testing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 84 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,029 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00084 $0.02029
Opus 5.5 $0.00034 $0.00812
Sonnet 5.5 $0.00017 $0.00406
Haiku 4.5 $0.00008 $0.00203

Measured yesterday against content hash 5417a5ecb70f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

dotnet-hosted-service-testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/probe-faketime.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.ai-badger/skills/dotnet-workload/references/dotnet-hosted-service-testing/SKILL.md · 58 lines

How it starts

The opening of the file, as written. The whole thing — 58 lines — stays where its author put it; the contents beside it link to each section on GitHub.

dotnet-hosted-service-testing

Trigger

  • Writing tests for a BackgroundService (ExecuteAsync loop, interval polling, periodic jobs).
  • Reviewing tests that use FakeTimeProvider / TimeProvider (e.g. Microsoft.Extensions.Time.Testing).
  • Judging whether hosted-service tests honestly cover the loop, interval, dedup, error-tolerance, and DI-registration paths.

FakeTimeProvider + BackgroundService semantics (empirically verified on .NET 10)

  1. StartAsync does NOT run ExecuteAsync on the caller thread. The loop body starts on a threadpool thread; StartAsync returns before the first pass runs. Consequence: time.Advance(...) immediately after StartAsync is reliably LOST — the Task.Delay/PeriodicTimer timer isn't registered yet. The first advance silently does nothing.
  2. Timer callbacks fire inline on the Advance caller thread, but the Task.Delay continuation is queued to the threadpool (RunContinuationsAsynchronously). After each Advance, give the continuation real time to land (await Task.Delay(100, TestContext.Current.CancellationToken)), then assert.
  3. Task.Delay(interval, timeProvider, token) registers its timer synchronously inside the call — but only when the loop reaches it. With fully-synchronous fakes (Task.FromResult everywhere), the first pass completes synchronously inside ExecuteAsync; the first real yield is the delay.
  4. A poll-loop test that passes via a lost first advance is fragile in both directions: it passes when the advance is lost, and FAILS (despite correct behavior) if the timer ever registers in time. Assert on an invocation counter in the fake (e.g. RunOnceAsync calls), not on side-effect counts.
  5. Side-effect counts encode fake artifacts. If the fake's shared index is never updated by ShareAsync, a second loop pass re-shares — expecting count == 2 documents fake behavior that can never happen in production (a real store would dedup the second pass). Test loop-iteration count; test dedup separately with a pre-populated index.
  6. A RunOnceAsync internal seam (called by ExecuteAsync, directly testable) is the right shape — test the pass logic through the seam, and the interval through the loop test.
  7. PeriodicTimer observables (verified .NET 10): the fake fires a periodic timer TWICE per Advance when two schedule points fall inside the window, and the loop's check runs asynchronously at the POST-advance clock — never at the tick's due time. A single large Advance past the deadline fires immediately regardless of tick size, so the tick period is unobservable via one big advance. Pin a tick period by split advances: keep the clock below the deadline until the cadence is established, then cross (recipe + numbers: references/watchdog-e2e-tick-cadence-and-di-signaling.md).
  8. StopApplication on a WebApplication host does NOT auto-stop the host (verified): it cancels ApplicationStopping and makes WaitForShutdownAsync return (the runner contract); ApplicationStopped fires only after the runner calls host.StopAsync()/dispose. For "watchdog shut the host down" assertions, assert the runner-shaped chain — ApplicationStopping token, then WaitForShutdownAsync completes, then StopAsync — not ApplicationStopped directly.
  9. Timing-sensitive fake-clock tests: re-run under the full-suite filter (parallel load can starve the 100ms settle) and REBUILD after test edits before judging flakiness — --no-build against a stale assembly reports phantom failures.
  10. Watchdog-style deadline services: derive the poll tick from the timeout (tick = min(60s, timeout/4)), not a fixed 60s — a fixed tick makes short-timeout gates unsatisfiable (a 2s-timeout host shuts down up to 62s late, so a "within ~5s" assertion can never pass) AND makes early-shutdown assertions vacuously true. The deadline-check granularity must be a fraction of the timeout at every scale; pin the derivation with a short-timeout test.
  11. Sync on the service's own log emissions, not wall-clock delays. When the loop's first action emits a [LoggerMessage] event (e.g. a startup-pass checkpoint), poll the FakeLogger collector snapshot instead of Task.Delay(50) before probing and Task.Delay(100) before asserting: WaitForLogAsync(eventId, count) — poll every ~10 ms up to a 5 s timeout, throw TimeoutException naming the expected event/count. Fixed delays race BOTH directions: a slow box misses the startup pass (the probe write lands before it, then the startup truncation breaks the assertion), and a fast box asserts before the tick's continuation lands. The service's own log emission is the deterministic sync point — the startup event doubles as the "timer registered" guarantee. (Applied 2026-08-07 to bank-maintenance lifecycle tests after review flagged the fixed-delay flake risk; the polling rewrite ran 4x stable.)

Read the full file on GitHub · 58 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 58 lines · 84 tokens per session scan A 5417a5ecb70f

Subscribe to this mod's changes

dotnet-hosted-service-testing is a skill published in the GitHub repository Arasz/ai-raccoon (7 stars, last pushed today), licensed MIT. It adds 84 tokens to every session and 2,029 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-12-05.

Related

dotnet-hosted-service-testing compared with skills from other repositories

dotnet-hosted-service-testing next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
dotnet-hosted-service-testingArasz/ai-raccoonSkill7todayMITA84Claude Code, Codex
http-client-migrationGen-Verse/PAST-BenchSkill404mo agoApache-2.0A14Claude Code, Codex
code-qualitywaybarrios/opencode-power-packSkill5625d agoMITA49Claude Code
compiler-b09bd196FuRongJun-1999/dsh-memorySkill778todayMITA104Claude Code
cartographer-kb-createBeppeTemp/cartographerSkill74yesterdayApache-2.0A53Claude Code, Codex
cartographer-kb-importBeppeTemp/cartographerSkill74yesterdayApache-2.0A51Claude Code, Codex
cartographer-kb-source-authorBeppeTemp/cartographerSkill74yesterdayApache-2.0A106Claude Code, Codex