[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DYV1HZQFB2KE8J0F52RE8W":3,"skill-same:01M6DYV1HZQFB2KE8J0F52RE8W":91},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":56,"repositoryHtmlUrl":57,"repositoryHomepageUrl":58,"ownerHtmlUrl":59,"ownerBlogUrl":60,"ownerDescription":61,"updatedAt":62,"install":63,"resources":76},"01M6DYV1HZQFB2KE8J0F52RE8W","nunit",null,"Write, run, or repair .NET tests that use NUnit. Use when a repo uses `NUnit`, `[Test]`, `[TestCase]`, `[TestFixture]`, or NUnit3TestAdapter for VSTest or Microsoft.Testing.Platform execution. USE FOR: writing or reviewing NUnit tests; using [Test], [TestCase], [TestFixture], [SetUp], [TearDown] attributes; configuring NUnit3TestAdapter or NUnit.Analyzers. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","managedcode\u002Fdotnet-skills","managedcode","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78253589?v=4","01M6DYDJR3EG8KB5G4PC65XCTT","Managed Code","01M6DYDJX0ZT432N04NYJW89DN",515,"MIT","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FNUnit\u002Fskills\u002Fnunit\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[5,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"unrelated","when","generic","inspect","attributes","relevant","tests","platform","commands","teardown","repair","do","files","testing","use","context","edit","write","repo","execution","repository","run","tasks","writing","2026-11-10 10:12:30",false,"---\nname: nunit\ndescription: \"Write, run, or repair .NET tests that use NUnit. Use when a repo uses `NUnit`, `[Test]`, `[TestCase]`, `[TestFixture]`, or NUnit3TestAdapter for VSTest or Microsoft.Testing.Platform execution. USE FOR: writing or reviewing NUnit tests; using [Test], [TestCase], [TestFixture], [SetUp], [TearDown] attributes; configuring NUnit3TestAdapter or NUnit.Analyzers. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.\"\n---\n\n# NUnit Testing\n\n## Diagnostic Output Budget\n\nKeep native test progress and ANSI visible; use the detected runner's supported flags (`--progress on --ansi on` for MTP\u002FTUnit), not MTP switches on VSTest. Keep console logs at `Warning` or higher and one concise final summary. Do not replay progress redraws, successful-test output, or Information\u002FDebug\u002FTrace logs into model context. On failure\u002Fcrash, show only the failing test\u002Fresource, root error, and relevant stack frames; deduplicate and cap each diagnostic response at 80 lines \u002F 8 KiB. Never dump entire console\u002Fhost\u002Fbrowser logs, HTML, TRX, or crash artifacts. Keep necessary artifacts size-bounded outside context, link them, and inspect exact bounded excerpts. Preserve the runner exit code through capture\u002Ffiltering; disclose truncation. Silence alone does not establish a hang.\n\n## Trigger On\n\n- writing or reviewing NUnit tests\n- using `[Test]`, `[TestCase]`, `[TestFixture]`, `[SetUp]`, `[TearDown]` attributes\n- configuring NUnit3TestAdapter or NUnit.Analyzers\n- migrating between NUnit versions\n- integrating NUnit with CI pipelines\n\n## Documentation\n\n- [NUnit Documentation](https:\u002F\u002Fdocs.nunit.org\u002F)\n- [NUnit GitHub](https:\u002F\u002Fgithub.com\u002Fnunit\u002Fnunit)\n- [NUnit3TestAdapter](https:\u002F\u002Fgithub.com\u002Fnunit\u002Fnunit3-vs-adapter)\n- [NUnit Analyzers](https:\u002F\u002Fgithub.com\u002Fnunit\u002Fnunit.analyzers)\n\n## Workflow\n\n1. Detect whether the project uses NUnit 3.x or 4.x and which runner path is active: VSTest, Microsoft.Testing.Platform, IDE runner, or CI wrapper.\n2. Keep test fixtures small, prefer focused assertions with `Assert.That`, and use `TestCase` or `TestCaseSource` only when parameterization improves signal.\n3. Add `NUnit3TestAdapter`, `Microsoft.NET.Test.Sdk`, and `NUnit.Analyzers` when CLI discovery or analyzer coverage is missing.\n4. Validate with the repo's real test command before changing assertion style or lifecycle hooks.\n\n### References\n\n- [patterns.md](references\u002Fpatterns.md) — Test patterns, assertions, parameterized tests, lifecycle\n- [anti-patterns.md](references\u002Fanti-patterns.md) — Common NUnit mistakes and fixes\n\n## Package Selection\n\n| Package | Purpose |\n|---------|---------|\n| `NUnit` | Core testing framework |\n| `NUnit3TestAdapter` | VSTest adapter for `dotnet test` |\n| `NUnit.Analyzers` | Roslyn analyzers for NUnit best practices |\n| `Microsoft.NET.Test.Sdk` | Required for test discovery |\n\n## Project Setup\n\n```xml\n\u003CProject Sdk=\"Microsoft.NET.Sdk\">\n  \u003CPropertyGroup>\n    \u003CTargetFramework>net8.0\u003C\u002FTargetFramework>\n    \u003CIsPackable>false\u003C\u002FIsPackable>\n    \u003CIsTestProject>true\u003C\u002FIsTestProject>\n  \u003C\u002FPropertyGroup>\n\n  \u003CItemGroup>\n    \u003CPackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.*\" \u002F>\n    \u003CPackageReference Include=\"NUnit\" Version=\"4.*\" \u002F>\n    \u003CPackageReference Include=\"NUnit3TestAdapter\" Version=\"4.*\" \u002F>\n    \u003CPackageReference Include=\"NUnit.Analyzers\" Version=\"4.*\">\n      \u003CPrivateAssets>all\u003C\u002FPrivateAssets>\n      \u003CIncludeAssets>runtime; build; native; contentfiles; analyzers\u003C\u002FIncludeAssets>\n    \u003C\u002FPackageReference>\n  \u003C\u002FItemGroup>\n\u003C\u002FProject>\n```\n\n## Test Patterns\n\n### Basic Test Structure\n\n```csharp\n[TestFixture]\npublic class CalculatorTests\n{\n    private Calculator _calculator;\n\n    [SetUp]\n    public void SetUp()\n    {\n        _calculator = new Calculator();\n    }\n\n    [TearDown]\n    public void TearDown()\n    {\n        _calculator?.Dispose();\n    }\n\n    [Test]\n    public void Add_TwoPositiveNumbers_ReturnsSum()\n    {\n        var result = _calculator.Add(2, 3);\n\n        Assert.That(result, Is.EqualTo(5));\n    }\n\n    [Test]\n    public void Divide_ByZero_ThrowsException()\n    {\n        Assert.Throws\u003CDivideByZeroException>(() => _calculator.Divide(10, 0));\n    }\n}\n```\n\n### Parameterized Tests with TestCase\n\n```csharp\n[TestFixture]\npublic class ValidationTests\n{\n    [TestCase(\"\", false)]\n    [TestCase(\"a\", false)]\n    [TestCase(\"ab\", false)]\n    [TestCase(\"abc\", true)]\n    [TestCase(\"valid@email.com\", true)]\n    public void IsValid_VariousInputs_ReturnsExpected(string input, bool expected)\n    {\n        var result = Validator.IsValid(input);\n\n        Assert.That(result, Is.EqualTo(expected));\n    }\n\n    [TestCase(1, 2, ExpectedResult = 3)]\n    [TestCase(-1, 1, ExpectedResult = 0)]\n    [TestCase(100, 200, ExpectedResult = 300)]\n    public int Add_TestCases_ReturnsExpectedResult(int a, int b)\n    {\n        return _calculator.Add(a, b);\n    }\n}\n```\n\n### TestCaseSource for Complex Data\n\n```csharp\n[TestFixture]\npublic class OrderTests\n{\n    private static IEnumerable\u003CTestCaseData> OrderTestCases()\n    {\n        yield return new TestCaseData(\n            new Order { Items = new[] { new Item { Price = 10 }, new Item { Price = 20 } } },\n            30m\n        ).SetName(\"TwoItems_CalculatesTotal\");\n\n        yield return new TestCaseData(\n            new Order { Items = Array.Empty\u003CItem>() },\n            0m\n        ).SetName(\"EmptyOrder_ReturnsZero\");\n\n        yield return new TestCaseData(\n            new Order { Items = new[] { new Item { Price = 100 } }, DiscountPercent = 10 },\n            90m\n        ).SetName(\"WithDiscount_AppliesDiscount\");\n    }\n\n    [TestCaseSource(nameof(OrderTestCases))]\n    public void CalculateTotal_VariousOrders_ReturnsExpected(Order order, decimal expected)\n    {\n        var result = order.CalculateTotal();\n\n        Assert.That(result, Is.EqualTo(expected));\n    }\n}\n```\n\n### Constraint-Based Assertions\n\n```csharp\n[Test]\npublic void AssertionExamples()\n{\n    \u002F\u002F Equality\n    Assert.That(actual, Is.EqualTo(expected));\n    Assert.That(actual, Is.Not.EqualTo(other));\n\n    \u002F\u002F Comparison\n    Assert.That(value, Is.GreaterThan(5));\n    Assert.That(value, Is.LessThanOrEqualTo(10));\n    Assert.That(value, Is.InRange(1, 100));\n\n    \u002F\u002F String\n    Assert.That(str, Does.StartWith(\"Hello\"));\n    Assert.That(str, Does.Contain(\"world\"));\n    Assert.That(str, Does.Match(@\"\\d{3}-\\d{4}\"));\n    Assert.That(str, Is.EqualTo(\"HELLO\").IgnoreCase);\n\n    \u002F\u002F Collection\n    Assert.That(list, Has.Count.EqualTo(5));\n    Assert.That(list, Contains.Item(\"expected\"));\n    Assert.That(list, Is.All.GreaterThan(0));\n    Assert.That(list, Is.Unique);\n    Assert.That(list, Is.Ordered);\n    Assert.That(list, Has.Exactly(3).Items.GreaterThan(10));\n\n    \u002F\u002F Type\n    Assert.That(obj, Is.InstanceOf\u003CMyClass>());\n    Assert.That(obj, Is.AssignableTo\u003CIMyInterface>());\n\n    \u002F\u002F Null\n    Assert.That(obj, Is.Null);\n    Assert.That(obj, Is.Not.Null);\n\n    \u002F\u002F Boolean\n    Assert.That(condition, Is.True);\n    Assert.That(condition, Is.False);\n\n    \u002F\u002F Exception\n    Assert.That(() => DoSomething(), Throws.TypeOf\u003CInvalidOperationException>());\n    Assert.That(() => DoSomething(), Throws.Exception.With.Message.Contains(\"error\"));\n\n    \u002F\u002F Async\n    Assert.That(async () => await DoAsync(), Throws.Nothing);\n}\n```\n\n### Async Test Support\n\n```csharp\n[TestFixture]\npublic class AsyncServiceTests\n{\n    private IAsyncService _service;\n\n    [SetUp]\n    public void SetUp()\n    {\n        _service = new AsyncService();\n    }\n\n    [Test]\n    public async Task GetDataAsync_ValidId_ReturnsData()\n    {\n        var result = await _service.GetDataAsync(1);\n\n        Assert.That(result, Is.Not.Null);\n        Assert.That(result.Id, Is.EqualTo(1));\n    }\n\n    [Test]\n    public void GetDataAsync_InvalidId_ThrowsException()\n    {\n        Assert.ThrowsAsync\u003CNotFoundException>(\n            async () => await _service.GetDataAsync(-1));\n    }\n\n    [Test]\n    public async Task ProcessAsync_CancellationRequested_ThrowsOperationCanceled()\n    {\n        using var cts = new CancellationTokenSource();\n        cts.Cancel();\n\n        Assert.ThrowsAsync\u003COperationCanceledException>(\n            async () => await _service.ProcessAsync(cts.Token));\n    }\n}\n```\n\n### OneTimeSetUp and OneTimeTearDown\n\n```csharp\n[TestFixture]\npublic class IntegrationTests\n{\n    private static TestServer _server;\n    private HttpClient _client;\n\n    [OneTimeSetUp]\n    public void OneTimeSetUp()\n    {\n        \u002F\u002F Runs once before all tests in fixture\n        _server = new TestServer(new WebHostBuilder().UseStartup\u003CStartup>());\n    }\n\n    [OneTimeTearDown]\n    public void OneTimeTearDown()\n    {\n        \u002F\u002F Runs once after all tests in fixture\n        _server?.Dispose();\n    }\n\n    [SetUp]\n    public void SetUp()\n    {\n        \u002F\u002F Runs before each test\n        _client = _server.CreateClient();\n    }\n\n    [TearDown]\n    public void TearDown()\n    {\n        \u002F\u002F Runs after each test\n        _client?.Dispose();\n    }\n\n    [Test]\n    public async Task GetEndpoint_ReturnsSuccess()\n    {\n        var response = await _client.GetAsync(\"\u002Fapi\u002Fdata\");\n        Assert.That(response.IsSuccessStatusCode, Is.True);\n    }\n}\n```\n\n## Categories and Filtering\n\n```csharp\n[TestFixture]\n[Category(\"Integration\")]\npublic class DatabaseTests\n{\n    [Test]\n    [Category(\"Slow\")]\n    public void SlowDatabaseTest() { }\n\n    [Test]\n    [Category(\"Fast\")]\n    public void FastDatabaseTest() { }\n}\n\n\u002F\u002F Run specific categories:\n\u002F\u002F dotnet test --filter \"Category=Fast\"\n\u002F\u002F dotnet test --filter \"Category!=Slow\"\n```\n\n## Anti-Patterns to Avoid\n\n| Anti-Pattern | Why It's Bad | Better Approach |\n|--------------|--------------|-----------------|\n| Multiple asserts without clear purpose | Hard to identify which assertion failed | One logical assertion per test or use `Assert.Multiple` |\n| Test interdependence | Tests fail unpredictably | Each test should be independent |\n| Hardcoded test data | Brittle tests | Use `TestCase` or `TestCaseSource` |\n| Testing implementation details | Breaks on refactoring | Test behavior, not internals |\n| Missing `[SetUp]`\u002F`[TearDown]` cleanup | Resource leaks | Always clean up resources |\n| Classic Assert syntax | Less readable | Use constraint model (`Assert.That`) |\n\n## Running Tests\n\n```bash\n# Run all tests\ndotnet test\n\n# VSTest: concise console results; MTP uses its own progress\u002FANSI flags\ndotnet test --logger \"console;verbosity=minimal\"\n\n# Filter by name\ndotnet test --filter \"FullyQualifiedName~CalculatorTests\"\n\n# Filter by category\ndotnet test --filter \"Category=Unit\"\n\n# Run in parallel\ndotnet test -- NUnit.NumberOfTestWorkers=4\n```\n\n## Deliver\n\n- NUnit tests following the Arrange-Act-Assert pattern\n- Parameterized tests with `[TestCase]` and `[TestCaseSource]`\n- Constraint-based assertions with `Assert.That`\n- Proper test lifecycle management\n\n## Validate\n\n- Tests are independent and isolated\n- No hardcoded test data where parameterization is appropriate\n- Async tests use `async Task` not `async void`\n- Resources are properly disposed in `[TearDown]` or `[OneTimeTearDown]`\n- NUnit.Analyzers enabled to catch common issues\n","# NUnit Testing\n\n## Diagnostic Output Budget\n\nKeep native test progress and ANSI visible; use the detected runner's supported flags (`--progress on --ansi on` for MTP\u002FTUnit), not MTP switches on VSTest. Keep console logs at `Warning` or higher and one concise final summary. Do not replay progress redraws, successful-test output, or Information\u002FDebug\u002FTrace logs into model context. On failure\u002Fcrash, show only the failing test\u002Fresource, root error, and relevant stack frames; deduplicate and cap each diagnostic response at 80 lines \u002F 8 KiB. Never dump entire console\u002Fhost\u002Fbrowser logs, HTML, TRX, or crash artifacts. Keep necessary artifacts size-bounded outside context, link them, and inspect exact bounded excerpts. Preserve the runner exit code through capture\u002Ffiltering; disclose truncation. Silence alone does not establish a hang.\n\n## Trigger On\n\n- writing or reviewing NUnit tests\n- using `[Test]`, `[TestCase]`, `[TestFixture]`, `[SetUp]`, `[TearDown]` attributes\n- configuring NUnit3TestAdapter or NUnit.Analyzers\n- migrating between NUnit versions\n- integrating NUnit with CI pipelines\n\n## Documentation\n\n- [NUnit Documentation](https:\u002F\u002Fdocs.nunit.org\u002F)\n- [NUnit GitHub](https:\u002F\u002Fgithub.com\u002Fnunit\u002Fnunit)\n- [NUnit3TestAdapter](https:\u002F\u002Fgithub.com\u002Fnunit\u002Fnunit3-vs-adapter)\n- [NUnit Analyzers](https:\u002F\u002Fgithub.com\u002Fnunit\u002Fnunit.analyzers)\n\n## Workflow\n\n1. Detect whether the project uses NUnit 3.x or 4.x and which runner path is active: VSTest, Microsoft.Testing.Platform, IDE runner, or CI wrapper.\n2. Keep test fixtures small, prefer focused assertions with `Assert.That`, and use `TestCase` or `TestCaseSource` only when parameterization improves signal.\n3. Add `NUnit3TestAdapter`, `Microsoft.NET.Test.Sdk`, and `NUnit.Analyzers` when CLI discovery or analyzer coverage is missing.\n4. Validate with the repo's real test command before changing assertion style or lifecycle hooks.\n\n### References\n\n- [patterns.md](references\u002Fpatterns.md) — Test patterns, assertions, parameterized tests, lifecycle\n- [anti-patterns.md](references\u002Fanti-patterns.md) — Common NUnit mistakes and fixes\n\n## Package Selection\n\n| Package | Purpose |\n|---------|---------|\n| `NUnit` | Core testing framework |\n| `NUnit3TestAdapter` | VSTest adapter for `dotnet test` |\n| `NUnit.Analyzers` | Roslyn analyzers for NUnit best practices |\n| `Microsoft.NET.Test.Sdk` | Required for test discovery |\n\n## Project Setup\n\n```xml\n\u003CProject Sdk=\"Microsoft.NET.Sdk\">\n  \u003CPropertyGroup>\n    \u003CTargetFramework>net8.0\u003C\u002FTargetFramework>\n    \u003CIsPackable>false\u003C\u002FIsPackable>\n    \u003CIsTestProject>true\u003C\u002FIsTestProject>\n  \u003C\u002FPropertyGroup>\n\n  \u003CItemGroup>\n    \u003CPackageReference Include=\"Microsoft.NET.Test.Sdk\" Version=\"17.*\" \u002F>\n    \u003CPackageReference Include=\"NUnit\" Version=\"4.*\" \u002F>\n    \u003CPackageReference Include=\"NUnit3TestAdapter\" Version=\"4.*\" \u002F>\n    \u003CPackageReference Include=\"NUnit.Analyzers\" Version=\"4.*\">\n      \u003CPrivateAssets>all\u003C\u002FPrivateAssets>\n      \u003CIncludeAssets>runtime; build; native; contentfiles; analyzers\u003C\u002FIncludeAssets>\n    \u003C\u002FPackageReference>\n  \u003C\u002FItemGroup>\n\u003C\u002FProject>\n```\n\n## Test Patterns\n\n### Basic Test Structure\n\n```csharp\n[TestFixture]\npublic class CalculatorTests\n{\n    private Calculator _calculator;\n\n    [SetUp]\n    public void SetUp()\n    {\n        _calculator = new Calculator();\n    }\n\n    [TearDown]\n    public void TearDown()\n    {\n        _calculator?.Dispose();\n    }\n\n    [Test]\n    public void Add_TwoPositiveNumbers_ReturnsSum()\n    {\n        var result = _calculator.Add(2, 3);\n\n        Assert.That(result, Is.EqualTo(5));\n    }\n\n    [Test]\n    public void Divide_ByZero_ThrowsException()\n    {\n        Assert.Throws\u003CDivideByZeroException>(() => _calculator.Divide(10, 0));\n    }\n}\n```\n\n### Parameterized Tests with TestCase\n\n```csharp\n[TestFixture]\npublic class ValidationTests\n{\n    [TestCase(\"\", false)]\n    [TestCase(\"a\", false)]\n    [TestCase(\"ab\", false)]\n    [TestCase(\"abc\", true)]\n    [TestCase(\"valid@email.com\", true)]\n    public void IsValid_VariousInputs_ReturnsExpected(string input, bool expected)\n    {\n        var result = Validator.IsValid(input);\n\n        Assert.That(result, Is.EqualTo(expected));\n    }\n\n    [TestCase(1, 2, ExpectedResult = 3)]\n    [TestCase(-1, 1, ExpectedResult = 0)]\n    [TestCase(100, 200, ExpectedResult = 300)]\n    public int Add_TestCases_ReturnsExpectedResult(int a, int b)\n    {\n        return _calculator.Add(a, b);\n    }\n}\n```\n\n### TestCaseSource for Complex Data\n\n```csharp\n[TestFixture]\npublic class OrderTests\n{\n    private static IEnumerable\u003CTestCaseData> OrderTestCases()\n    {\n        yield return new TestCaseData(\n            new Order { Items = new[] { new Item { Price = 10 }, new Item { Price = 20 } } },\n            30m\n        ).SetName(\"TwoItems_CalculatesTotal\");\n\n        yield return new TestCaseData(\n            new Order { Items = Array.Empty\u003CItem>() },\n            0m\n        ).SetName(\"EmptyOrder_ReturnsZero\");\n\n        yield return new TestCaseData(\n            new Order { Items = new[] { new Item { Price = 100 } }, DiscountPercent = 10 },\n            90m\n        ).SetName(\"WithDiscount_AppliesDiscount\");\n    }\n\n    [TestCaseSource(nameof(OrderTestCases))]\n    public void CalculateTotal_VariousOrders_ReturnsExpected(Order order, decimal expected)\n    {\n        var result = order.CalculateTotal();\n\n        Assert.That(result, Is.EqualTo(expected));\n    }\n}\n```\n\n### Constraint-Based Assertions\n\n```csharp\n[Test]\npublic void AssertionExamples()\n{\n    \u002F\u002F Equality\n    Assert.That(actual, Is.EqualTo(expected));\n    Assert.That(actual, Is.Not.EqualTo(other));\n\n    \u002F\u002F Comparison\n    Assert.That(value, Is.GreaterThan(5));\n    Assert.That(value, Is.LessThanOrEqualTo(10));\n    Assert.That(value, Is.InRange(1, 100));\n\n    \u002F\u002F String\n    Assert.That(str, Does.StartWith(\"Hello\"));\n    Assert.That(str, Does.Contain(\"world\"));\n    Assert.That(str, Does.Match(@\"\\d{3}-\\d{4}\"));\n    Assert.That(str, Is.EqualTo(\"HELLO\").IgnoreCase);\n\n    \u002F\u002F Collection\n    Assert.That(list, Has.Count.EqualTo(5));\n    Assert.That(list, Contains.Item(\"expected\"));\n    Assert.That(list, Is.All.GreaterThan(0));\n    Assert.That(list, Is.Unique);\n    Assert.That(list, Is.Ordered);\n    Assert.That(list, Has.Exactly(3).Items.GreaterThan(10));\n\n    \u002F\u002F Type\n    Assert.That(obj, Is.InstanceOf\u003CMyClass>());\n    Assert.That(obj, Is.AssignableTo\u003CIMyInterface>());\n\n    \u002F\u002F Null\n    Assert.That(obj, Is.Null);\n    Assert.That(obj, Is.Not.Null);\n\n    \u002F\u002F Boolean\n    Assert.That(condition, Is.True);\n    Assert.That(condition, Is.False);\n\n    \u002F\u002F Exception\n    Assert.That(() => DoSomething(), Throws.TypeOf\u003CInvalidOperationException>());\n    Assert.That(() => DoSomething(), Throws.Exception.With.Message.Contains(\"error\"));\n\n    \u002F\u002F Async\n    Assert.That(async () => await DoAsync(), Throws.Nothing);\n}\n```\n\n### Async Test Support\n\n```csharp\n[TestFixture]\npublic class AsyncServiceTests\n{\n    private IAsyncService _service;\n\n    [SetUp]\n    public void SetUp()\n    {\n        _service = new AsyncService();\n    }\n\n    [Test]\n    public async Task GetDataAsync_ValidId_ReturnsData()\n    {\n        var result = await _service.GetDataAsync(1);\n\n        Assert.That(result, Is.Not.Null);\n        Assert.That(result.Id, Is.EqualTo(1));\n    }\n\n    [Test]\n    public void GetDataAsync_InvalidId_ThrowsException()\n    {\n        Assert.ThrowsAsync\u003CNotFoundException>(\n            async () => await _service.GetDataAsync(-1));\n    }\n\n    [Test]\n    public async Task ProcessAsync_CancellationRequested_ThrowsOperationCanceled()\n    {\n        using var cts = new CancellationTokenSource();\n        cts.Cancel();\n\n        Assert.ThrowsAsync\u003COperationCanceledException>(\n            async () => await _service.ProcessAsync(cts.Token));\n    }\n}\n```\n\n### OneTimeSetUp and OneTimeTearDown\n\n```csharp\n[TestFixture]\npublic class IntegrationTests\n{\n    private static TestServer _server;\n    private HttpClient _client;\n\n    [OneTimeSetUp]\n    public void OneTimeSetUp()\n    {\n        \u002F\u002F Runs once before all tests in fixture\n        _server = new TestServer(new WebHostBuilder().UseStartup\u003CStartup>());\n    }\n\n    [OneTimeTearDown]\n    public void OneTimeTearDown()\n    {\n        \u002F\u002F Runs once after all tests in fixture\n        _server?.Dispose();\n    }\n\n    [SetUp]\n    public void SetUp()\n    {\n        \u002F\u002F Runs before each test\n        _client = _server.CreateClient();\n    }\n\n    [TearDown]\n    public void TearDown()\n    {\n        \u002F\u002F Runs after each test\n        _client?.Dispose();\n    }\n\n    [Test]\n    public async Task GetEndpoint_ReturnsSuccess()\n    {\n        var response = await _client.GetAsync(\"\u002Fapi\u002Fdata\");\n        Assert.That(response.IsSuccessStatusCode, Is.True);\n    }\n}\n```\n\n## Categories and Filtering\n\n```csharp\n[TestFixture]\n[Category(\"Integration\")]\npublic class DatabaseTests\n{\n    [Test]\n    [Category(\"Slow\")]\n    public void SlowDatabaseTest() { }\n\n    [Test]\n    [Category(\"Fast\")]\n    public void FastDatabaseTest() { }\n}\n\n\u002F\u002F Run specific categories:\n\u002F\u002F dotnet test --filter \"Category=Fast\"\n\u002F\u002F dotnet test --filter \"Category!=Slow\"\n```\n\n## Anti-Patterns to Avoid\n\n| Anti-Pattern | Why It's Bad | Better Approach |\n|--------------|--------------|-----------------|\n| Multiple asserts without clear purpose | Hard to identify which assertion failed | One logical assertion per test or use `Assert.Multiple` |\n| Test interdependence | Tests fail unpredictably | Each test should be independent |\n| Hardcoded test data | Brittle tests | Use `TestCase` or `TestCaseSource` |\n| Testing implementation details | Breaks on refactoring | Test behavior, not internals |\n| Missing `[SetUp]`\u002F`[TearDown]` cleanup | Resource leaks | Always clean up resources |\n| Classic Assert syntax | Less readable | Use constraint model (`Assert.That`) |\n\n## Running Tests\n\n```bash\n# Run all tests\ndotnet test\n\n# VSTest: concise console results; MTP uses its own progress\u002FANSI flags\ndotnet test --logger \"console;verbosity=minimal\"\n\n# Filter by name\ndotnet test --filter \"FullyQualifiedName~CalculatorTests\"\n\n# Filter by category\ndotnet test --filter \"Category=Unit\"\n\n# Run in parallel\ndotnet test -- NUnit.NumberOfTestWorkers=4\n```\n\n## Deliver\n\n- NUnit tests following the Arrange-Act-Assert pattern\n- Parameterized tests with `[TestCase]` and `[TestCaseSource]`\n- Constraint-based assertions with `Assert.That`\n- Proper test lifecycle management\n\n## Validate\n\n- Tests are independent and isolated\n- No hardcoded test data where parameterization is appropriate\n- Async tests use `async Task` not `async void`\n- Resources are properly disposed in `[TearDown]` or `[OneTimeTearDown]`\n- NUnit.Analyzers enabled to catch common issues\n",{"name":5,"description":7},"main","497cc9aba79a931ac6fb8d36a48cc22fe3d6d74b","catalog\u002FTesting\u002FNUnit\u002Fskills\u002Fnunit",41,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills","https:\u002F\u002Fskills.managed-code.com","https:\u002F\u002Fgithub.com\u002Fmanagedcode","https:\u002F\u002Fwww.managed-code.com","Open Source Community for .NET Developers: Reliable, Actively Maintained, and Community-Driven. Made in Ukraine 🇺🇦 with ❤️","2026-11-14 19:05:44",{"source":8,"skillName":5,"commands":64,"prompt":74,"zipAvailable":75},[65,68,71],{"tool":66,"command":67},"npx","npx skills add managedcode\u002Fdotnet-skills --skill nunit",{"tool":69,"command":70},"bunx","bunx skills add managedcode\u002Fdotnet-skills --skill nunit",{"tool":72,"command":73},"pnpm","pnpm dlx skills add managedcode\u002Fdotnet-skills --skill nunit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FNUnit\u002Fskills\u002Fnunit\u002FSKILL.md",true,[77,83,87],{"path":78,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":81,"sourceHtmlUrl":82},"manifest.json","REFERENCE","参考文档",198,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FNUnit\u002Fskills\u002Fnunit\u002Fmanifest.json",{"path":84,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fanti-patterns.md",10407,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FNUnit\u002Fskills\u002Fnunit\u002Freferences\u002Fanti-patterns.md",{"path":88,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":89,"sourceHtmlUrl":90},"references\u002Fpatterns.md",8369,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FTesting\u002FNUnit\u002Fskills\u002Fnunit\u002Freferences\u002Fpatterns.md",[92,121,142,172,182,208],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":106,"publishedAt":48},"01M6DYQE1Y9FHAQHEDTVFQ3447","xtwitter-scraper","Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook\u002Fevent flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FXTwitterScraper\u002Fskills\u002Fxtwitter-scraper\u002FSKILL.md",[98,101],{"categoryNo":99,"categoryName":100,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":102,"categoryName":103,"taxonomyType":104,"taxonomyTypeDesc":105},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[107,108,109,45,110,111,112,44,113,114,115,116,40,24,117,36,118,32,119,120],"xtwitter scraper","browser automation","workflows","code","browser","search","api","Media","api client","access","webhooks","social","modeling","webhook",{"skillNo":122,"name":123,"nameZh":6,"description":124,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":133,"publishedAt":48},"01M6DYQ9S4PE1H6G8MCH9T21HR","sep","Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser\u002Fwriter options, and low-allocation row\u002Fcolumn workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FSep\u002Fskills\u002Fsep\u002FSKILL.md",[127,130],{"categoryNo":128,"categoryName":129,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":131,"categoryName":132,"taxonomyType":104,"taxonomyTypeDesc":105},"01JBSEEDCAT000000000000036","内容创作者",[123,47,134,109,46,45,44,135,136,137,40,39,24,36,35,138,139,140,32,141],"performance","data","parsing","parser","writer","options","project","high-performance",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":48},"01M6DZS2DNEPXCGGF6SSCW6G5V","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fwebgpu-claude-skill\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[149,150,151,152,153,154,155,156,157,158,159,160,38,161,162,163,164,165,166,167,168,169,170,171,25],"webgpu","threejs","webgpu threejs tsl","setup","shaders","gpu","integration","applications","js","node","syntax","guide","language","three","compute","post","processing","with","renderer","for","materials","wgsl","effects",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":178,"publishedAt":48},"01M6DZS0BQXW2B56A289XF1X76","roslynk","Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Froslynk\u002Fskills\u002Froslynk\u002FSKILL.md",[],[174,38,36,179,180,168,181],"semantic","razor","inspection",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":188,"publishedAt":48},"01M6DZRW6MEJCVW80K3S4XV60K","system-text-json-net11","Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md",[],[189,190,191,192,47,193,194,195,196,197,198,38,199,200,201,202,35,203,204,205,206,168,207,26,25],"system","json","text","system text json net11","policy","metadata","library","serialization","behavior","user","only","probe","guidance","later","type","dictionary","naming","targeting","custom",{"skillNo":209,"name":210,"nameZh":6,"description":211,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":212,"categories":213,"keywords":216,"publishedAt":48},"01M6DZRRJP3S662NFSG1RSPQQ7","process-api-net11","Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText\u002FBytes\u002FLines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fprocess-api-net11\u002FSKILL.md",[214,215],{"categoryNo":99,"categoryName":100,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":102,"categoryName":103,"taxonomyType":104,"taxonomyTypeDesc":105},[113,217,218,219,45,220,156,189,38,201,202,35,221,222,223,224,206,168,225],"process","process api net11","diagnostics","start","basic","processes","output","usage","new"]