xunit-testing-patterns

Generates xUnit integration tests with Shouldly assertions for ASP.NET Zero application services.

Updated May 22, 2026
One-click install
npx skills add https://github.com/shakesoft/timekeeper --skill xunit-testing-patterns-shakesoft
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: xunit-testing-patterns
Source: https://github.com/shakesoft/timekeeper/tree/main/.cursor/skills/xunit-testing-patterns
Command: npx skills add https://github.com/shakesoft/timekeeper --skill xunit-testing-patterns-shakesoft

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent integration tests for ASP.NET Zero application services requires knowledge of the framework's test infrastructure, including AppTestBase, session management, and multi-tenancy handling. This Skill provides ready-to-use patterns so tests follow team conventions without repeatedly looking up boilerplate. ## Core Features & Use Cases - CRUD Test Templates: Provides complete test patterns for Get, GetForEdit, Create, Update, and Delete operations on application services, including database verification via UsingDbContext. - Shouldly Assertion Reference: Supplies fluent assertion examples for equality, null checks, collections, comparisons, and booleans. - Multi-Tenancy & Exception Testing: Covers MultiTenantFact/MultiTenantTheory attributes and Assert.ThrowsAsync patterns for UserFriendlyException scenarios. - Use Case: When adding a new ProductAppService, use this Skill to scaffold a ProductAppService_Tests class that inherits AppTestBase, logs in as host admin, resolves the service from DI, and tests all CRUD operations with Shouldly assertions. ## Quick Start Write xUnit tests for my ProductAppService covering create, update, delete, and list operations following the ASP.NET Zero testing patterns.

Frequently Asked Questions about xunit-testing-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write xUnit tests for ASP.NET Zero app services?▼

Create a test class inheriting AppTestBase, call LoginAsHostAdmin in the constructor, and resolve the service with Resolve<IYourAppService>(). Use [Fact] attributes and Shouldly assertions, verifying database state with UsingDbContext or UsingDbContextAsync.

How to test multi-tenant features in ASP.NET Zero?▼

Use the [MultiTenantFact] or [MultiTenantTheory] attributes instead of [Fact] so tests only run when multi-tenancy is enabled. Verify TenantId on created entities using AbpSession.TenantId within UsingDbContextAsync assertions.

Shouldly vs FluentAssertions for xUnit testing?▼

This project standardizes on Shouldly for assertions, using methods like ShouldBe, ShouldNotBeNull, ShouldContain, and ShouldBeGreaterThan. Shouldly produces readable failure messages and integrates directly with xUnit test workflows.

How do I test exceptions thrown by app services?▼

Use Assert.ThrowsAsync<UserFriendlyException> with an async lambda calling the service method, then assert on the exception message with ShouldContain. This validates business rules like preventing deletion of products with orders.

Why is my deleted entity still appearing in test queries?▼

ASP.NET Zero uses soft deletion, so deleted entities are filtered out by default query filters. A FirstOrDefault lookup after DeleteProduct should return null, which is the correct assertion for verifying soft deletion.