30 lines
1.2 KiB
Plaintext
30 lines
1.2 KiB
Plaintext
|
|
# Evidence: WorkItem State Machine Invalid Transitions Validation
|
||
|
|
|
||
|
|
All invalid transition tests verified to throw InvalidOperationException:
|
||
|
|
|
||
|
|
✓ Open_ToDone_Throws - Cannot skip states
|
||
|
|
✓ Open_ToInProgress_Throws - Must assign first
|
||
|
|
✓ Assigned_ToDone_Throws - Must go through review
|
||
|
|
✓ InProgress_ToOpen_Throws - No backwards transition
|
||
|
|
✓ Done_ToAnyStatus_Throws - Terminal state enforcement
|
||
|
|
|
||
|
|
State machine implementation correctly enforces:
|
||
|
|
- Valid transitions: Open → Assigned → InProgress → Review → Done
|
||
|
|
- Rework allowed: Review → InProgress
|
||
|
|
- All invalid transitions throw InvalidOperationException
|
||
|
|
|
||
|
|
Implementation in WorkClub.Domain/Entities/WorkItem.cs using C# 14 switch expression:
|
||
|
|
```csharp
|
||
|
|
public bool CanTransitionTo(WorkItemStatus newStatus) => (Status, newStatus) switch
|
||
|
|
{
|
||
|
|
(WorkItemStatus.Open, WorkItemStatus.Assigned) => true,
|
||
|
|
(WorkItemStatus.Assigned, WorkItemStatus.InProgress) => true,
|
||
|
|
(WorkItemStatus.InProgress, WorkItemStatus.Review) => true,
|
||
|
|
(WorkItemStatus.Review, WorkItemStatus.Done) => true,
|
||
|
|
(WorkItemStatus.Review, WorkItemStatus.InProgress) => true,
|
||
|
|
_ => false
|
||
|
|
};
|
||
|
|
```
|
||
|
|
|
||
|
|
All 12 test cases passed successfully.
|