create-unit-test

Generates xUnit test classes with Moq setups for ECommerceApp services, handlers, and aggregates.

Updated Nov 19, 2020
One-click install
npx skills add https://github.com/kwojtasinski-repo/ECommerceApp --skill create-unit-test-kwojtasinski-repo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-unit-test
Source: https://github.com/kwojtasinski-repo/ECommerceApp/tree/main/.github/skills/create-unit-test
Command: npx skills add https://github.com/kwojtasinski-repo/ECommerceApp --skill create-unit-test-kwojtasinski-repo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing unit tests that follow a project's established conventions is repetitive and error-prone. This Skill scaffolds xUnit test classes that match the ECommerceApp testing standards, so developers get consistent, correctly structured tests without memorizing every convention. ## Core Features & Use Cases - Three test templates: Generates Moq-based service tests, mock-free aggregate tests, and handler tests with repository verification. - Convention enforcement: Applies naming rules (MethodName_Scenario_ExpectedResult), CreateSut/CreateHandler factory methods, FluentAssertions, and CancellationToken usage automatically. - Correct file placement: Places tests under ECommerceApp.UnitTests for both new bounded-context modules and legacy services. - Use Case: After adding a new OrderPaymentConfirmedHandler in the Sales/Orders bounded context, generate a handler test class with mocked repository, Arrange/Act/Assert stubs, and verification of update calls. ## Quick Start Ask the assistant to create a unit test for a given service or handler name, optionally specifying the bounded context path such as Sales/Orders.

Frequently Asked Questions about create-unit-test

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

FAQPage Schema
How do I create a unit test for a C# service with Moq?

Provide the service or class name and this Skill generates an xUnit test class with Mock fields initialized in the constructor, a private CreateSut factory method, and Arrange/Act/Assert test stubs using FluentAssertions.

How to write unit tests for message handlers in .NET?

The handler template creates a test class with a mocked repository, a CreateHandler factory, and a CreateMessage helper. It includes stubs for verifying repository calls with Times.Once or Times.Never based on the scenario.

Where are generated unit test files placed in the project?

New bounded-context tests go under ECommerceApp.UnitTests/<Module>/<BC>/, such as Sales/Orders. Legacy service tests go under ECommerceApp.UnitTests/Services/<Domain>/.

Does the test template use FluentAssertions or Assert?

The templates use FluentAssertions exclusively, calling Should() on results and Throw<DomainException>() for exception cases. Raw Assert statements are not used per project conventions.

Can I generate tests for domain aggregates without mocks?

Yes, the aggregate template contains no mocks. It tests factory methods like Create with valid parameters and verifies DomainException is thrown with the expected message for invalid input.