mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 08:23:12 +00:00
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
|
|
using Data.SeaHavenIndustries.Enums;
|
||
|
|
using SeaHaven.Services.Helpers;
|
||
|
|
|
||
|
|
namespace SeaHavenIndustries.Tests;
|
||
|
|
|
||
|
|
public class WorkOrderBoardMutationRulesTests
|
||
|
|
{
|
||
|
|
[Theory]
|
||
|
|
[InlineData(LifecycleStatus.Canceled, true)]
|
||
|
|
[InlineData(LifecycleStatus.Closed, true)]
|
||
|
|
[InlineData(LifecycleStatus.Complete, true)]
|
||
|
|
[InlineData(LifecycleStatus.Scheduled, false)]
|
||
|
|
[InlineData(LifecycleStatus.Incomplete, false)]
|
||
|
|
public void IsReadOnly_ReflectsTerminalStatuses(LifecycleStatus status, bool expected)
|
||
|
|
{
|
||
|
|
Assert.Equal(expected, WorkOrderBoardMutationRules.IsReadOnly(status));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void ShouldBlockStatusChangeWhenPastDue_BlocksOnlyLifecycleStatus()
|
||
|
|
{
|
||
|
|
Assert.True(WorkOrderBoardMutationRules.ShouldBlockStatusChangeWhenPastDue(
|
||
|
|
WorkOrderBoardFieldNames.LifecycleStatus, isPastDue: true));
|
||
|
|
Assert.False(WorkOrderBoardMutationRules.ShouldBlockStatusChangeWhenPastDue(
|
||
|
|
WorkOrderBoardFieldNames.ScheduledDate, isPastDue: true));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void ShouldAutoSchedule_WhenIncompleteWithDateAndAssignee()
|
||
|
|
{
|
||
|
|
Assert.True(WorkOrderBoardMutationRules.ShouldAutoSchedule(
|
||
|
|
LifecycleStatus.Incomplete,
|
||
|
|
new DateTime(2026, 6, 25),
|
||
|
|
"dispatcher-1"));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void ShouldAutoSchedule_FalseWhenAlreadyScheduled()
|
||
|
|
{
|
||
|
|
Assert.False(WorkOrderBoardMutationRules.ShouldAutoSchedule(
|
||
|
|
LifecycleStatus.Scheduled,
|
||
|
|
new DateTime(2026, 6, 25),
|
||
|
|
"dispatcher-1"));
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void IsReschedule_WhenPreviousDateExistsAndChanges()
|
||
|
|
{
|
||
|
|
Assert.True(WorkOrderBoardMutationRules.IsReschedule(
|
||
|
|
new DateTime(2026, 6, 20),
|
||
|
|
new DateTime(2026, 6, 25)));
|
||
|
|
Assert.False(WorkOrderBoardMutationRules.IsReschedule(
|
||
|
|
null,
|
||
|
|
new DateTime(2026, 6, 25)));
|
||
|
|
}
|
||
|
|
}
|