Files
Amaury Levé 948a9a52ef Add exp-mock-usage-analysis skill and evaluation (#483)
* Add exp-mock-usage-analysis skill and evaluation

New experimental skill that detects unused, redundant, or unnecessary
mocks in .NET test suites. Covers Moq, NSubstitute, FakeItEasy, and
manual test doubles.

- SKILL.md with 6-step workflow: gather code, classify mocks, detect
  anti-patterns, incorporate runtime data, generate recommendations,
  report findings
- eval.yaml with 10 scenarios: trivial type mocking, unused setups,
  redundant configs, stable utility mocks, well-placed mocks (no false
  positives), NSubstitute support, FakeItEasy support, setup sprawl,
  and 2 non-activation boundary tests
- Fixture files for each scenario with production + test code
- CODEOWNERS entry for @dotnet/dotnet-testing

* Remove no-headroom scenarios, increase NSubstitute timeout

Remove 4 scenarios where baseline already scores 5.0/5 (model handles
these well without skill guidance):
- Detect mocking of DTOs, records, and enums
- Recognize well-placed mocks without inventing false positives
- Decline when asked about non-mock test anti-patterns
- Decline mock framework migration request

Increase NSubstitute scenario timeout from 120s to 180s to avoid
baseline timeouts impacting scoring.

Remaining 6 scenarios all show positive skill impact (3→5, 3→4, etc).

* Document areas the model handles well without the skill

Add a subsection under 'When Not to Use' listing mock-related tasks
where the base model already scores 5.0/5 without skill guidance:
- Mocking trivial types (DTOs, records, enums)
- Recognizing well-placed mocks (no false positives)

* Fix md

* Improve
2026-04-02 10:03:17 +00:00

59 lines
1.6 KiB
C#

namespace Billing;
public interface IPaymentGateway
{
PaymentResult Charge(string customerId, decimal amount);
PaymentResult Refund(string transactionId, decimal amount);
}
public interface IInvoiceStore
{
void Save(Invoice invoice);
Invoice? GetById(string invoiceId);
}
public interface ICustomerLookup
{
Customer? GetById(int customerId);
}
public record PaymentResult(bool Success, string TransactionId, string? ErrorMessage);
public record Invoice(string InvoiceId, int CustomerId, decimal Amount, DateTime CreatedAt);
public record Customer(int Id, string Name, string Email);
public class BillingService
{
private readonly IPaymentGateway _gateway;
private readonly IInvoiceStore _invoiceStore;
private readonly ICustomerLookup _customerLookup;
public BillingService(IPaymentGateway gateway, IInvoiceStore invoiceStore, ICustomerLookup customerLookup)
{
_gateway = gateway;
_invoiceStore = invoiceStore;
_customerLookup = customerLookup;
}
public PaymentResult ChargeCustomer(int customerId, decimal amount)
{
var customer = _customerLookup.GetById(customerId)
?? throw new InvalidOperationException($"Customer {customerId} not found");
var result = _gateway.Charge(customer.Id.ToString(), amount);
if (result.Success)
{
var invoice = new Invoice(
Guid.NewGuid().ToString(),
customerId,
amount,
DateTime.UtcNow);
_invoiceStore.Save(invoice);
}
return result;
}
}