一键导入
test
Add or modify tests following project conventions. Use when asked to write tests, add test coverage, or fix failing tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add or modify tests following project conventions. Use when asked to write tests, add test coverage, or fix failing tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Add or modify tests for PhotoManager following project conventions. Use this skill when asked to write tests, add test coverage, or fix failing tests.
Avalonia UI reference guide for PhotoManager: UI conventions, MVVM patterns, and cross-platform UI patterns. Use this skill when working on UI code, adding image-processing methods, or needing to understand the Avalonia UI layer of the application.
Refactor code following Clean Architecture patterns. Use when asked to restructure, extract, move, or reorganize code while preserving behavior.
Avalonia UI reference guide for PhotoManager: UI conventions, MVVM patterns, and cross-platform UI patterns. Use this skill when working on UI code, adding image-processing methods, or needing to understand the Avalonia UI layer of the application.
Refactor PhotoManager code following Clean Architecture patterns. Use this skill when asked to restructure, extract, move, or reorganize code while preserving behavior.
Implement a new feature for PhotoManager with full workflow. Use when asked to add new functionality, implement a user story, or add a new capability.
| name | test |
| description | Add or modify tests following project conventions. Use when asked to write tests, add test coverage, or fix failing tests. |
| disable-model-invocation | true |
| argument-hint | <class or method to test> |
You are tasked with adding or modifying tests for: $ARGUMENTS
Follow this workflow in order:
Read existing tests to understand patterns. Good references:
PhotoManager.Tests/ directory structure*Tests.cs files matching the class you are testingFollow this exact test structure:
[TestFixture]
public class ClassNameTests
{
private string? _assetsDirectory;
private string? _databaseDirectory;
private TestLogger<ClassName> _testLogger = new();
[OneTimeSetUp]
public void OneTimeSetUp()
{
_assetsDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, Directories.TEST_FILES);
_databaseDirectory = Path.Combine(_assetsDirectory, Directories.DATABASE_TESTS);
}
[SetUp]
public void SetUp()
{
_testLogger = new TestLogger<ClassName>();
}
[TearDown]
public void TearDown()
{
_testableAssetRepository?.Dispose();
TearDownHelper.DeleteTempDbDirectories(_databaseDirectory!);
_testLogger.LoggingAssertTearDown();
}
[Test]
public void MethodName_Situation_ExpectedResult()
{
// Arrange / Act / Assert
_testLogger.AssertLogExceptions([], typeof(ClassName));
}
}
For static methods, use TestLogger<ClassNameTests> instead.
Using directives (NON-NEGOTIABLE):
PhotoManager.Tests/GlobalUsings.cs BEFORE adding any usingUse existing helpers (NEVER duplicate):
TestLogger<T> — for all logging verificationDirectoryHelper — for directory access control testsImageHelper — for creating invalid test imagesPhotoManager.Tests.Unit.Constants namespaceAlways verify log output in assertions:
_testLogger.AssertLogInfos(messages, typeof(Service))_testLogger.AssertLogErrors(messages, typeof(Service))_testLogger.AssertLogExceptions(exceptions, typeof(Service))Always cleanup resources with finally blocks:
try
{
Directory.CreateDirectory(testDir);
// test code
}
finally
{
Directory.Delete(testDir, true);
}
Test naming (NON-NEGOTIABLE): MethodName_Situation_ExpectedResult
CalculateHash_ValidFile_ReturnsHashValue, DeleteAsset_AssetExists_RemovesAssetFromDatabase100% coverage required for all new code — every branch, exception path, and edge case must be tested.
Cross-platform (NON-NEGOTIABLE): tests run on Windows, Linux, and macOS CI and must pass on all three.
On Linux/macOS \ is not a path separator and C:\... paths are not rooted, so Path.* calls diverge from Windows (e.g. Path.GetFileName(@"C:\a\b.png") returns the whole string).
Path API.
Wrap it with PathHelper.ToPlatformAbsolutePath(@"C:\Dir"), or use PathHelper.ToResolvedConfigPath(...) for a path resolved by UserConfigurationService.Path.Combine exactly as production does — never Path.GetFullPath(@"...\name").
Reference test files with their exact on-disk case (Linux is case-sensitive).Build: Run dotnet build PhotoManager/PhotoManager.slnx and ensure zero warnings.
Run tests: Run dotnet test --filter "FullyQualifiedName~ClassName" PhotoManager/PhotoManager.slnx
using the appropriate class name filter.
Return a summary of tests added/modified with test results.