mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
Deliver PATCH board field updates and drop phases 3-7 code from the branch while keeping phase 0/1 dependencies required to build and test.
80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using Data.SeaHavenIndustries.Enums;
|
||
using SeaHaven.Services.Helpers;
|
||
|
||
namespace SeaHavenIndustries.Tests;
|
||
|
||
public class WorkOrderDerivedFieldsTests
|
||
{
|
||
private static readonly DateTime Today = new(2026, 6, 24, 12, 0, 0, DateTimeKind.Utc);
|
||
|
||
[Fact]
|
||
public void IsPastDue_WhenScheduledBeforeTodayAndNotTerminal_ReturnsTrue()
|
||
{
|
||
var result = WorkOrderDerivedFields.IsPastDue(
|
||
Today.AddDays(-1),
|
||
LifecycleStatus.Scheduled,
|
||
Today);
|
||
|
||
Assert.True(result);
|
||
}
|
||
|
||
[Fact]
|
||
public void IsPastDue_WhenScheduledToday_ReturnsFalse()
|
||
{
|
||
var result = WorkOrderDerivedFields.IsPastDue(
|
||
Today,
|
||
LifecycleStatus.Scheduled,
|
||
Today);
|
||
|
||
Assert.False(result);
|
||
}
|
||
|
||
[Fact]
|
||
public void IsPastDue_WhenComplete_ReturnsFalse()
|
||
{
|
||
var result = WorkOrderDerivedFields.IsPastDue(
|
||
Today.AddDays(-3),
|
||
LifecycleStatus.Complete,
|
||
Today);
|
||
|
||
Assert.False(result);
|
||
}
|
||
|
||
[Fact]
|
||
public void IsPastDue_WhenNoScheduledDate_ReturnsFalse()
|
||
{
|
||
var result = WorkOrderDerivedFields.IsPastDue(null, LifecycleStatus.Incomplete, Today);
|
||
Assert.False(result);
|
||
}
|
||
|
||
[Theory]
|
||
[InlineData(DayOfWeek.Monday, "monday")]
|
||
[InlineData(DayOfWeek.Friday, "friday")]
|
||
[InlineData(DayOfWeek.Saturday, null)]
|
||
public void GetDayGroup_MapsWeekdays(DayOfWeek day, string? expected)
|
||
{
|
||
var date = new DateTime(2026, 6, 22, 0, 0, 0, DateTimeKind.Utc);
|
||
while (date.DayOfWeek != day)
|
||
date = date.AddDays(1);
|
||
|
||
Assert.Equal(expected, WorkOrderDerivedFields.GetDayGroup(date));
|
||
}
|
||
|
||
[Fact]
|
||
public void FormatApptTime_WithStartAndEnd_ReturnsRange()
|
||
{
|
||
var start = new DateTime(2026, 6, 24, 7, 0, 0);
|
||
var end = new DateTime(2026, 6, 24, 9, 0, 0);
|
||
|
||
var result = WorkOrderDerivedFields.FormatApptTime(start, end);
|
||
|
||
Assert.Equal("07:00 – 09:00", result);
|
||
}
|
||
|
||
[Fact]
|
||
public void FormatApptTime_WithStartOnly_ReturnsTime()
|
||
{
|
||
var start = new DateTime(2026, 6, 24, 7, 30, 0);
|
||
Assert.Equal("07:30", WorkOrderDerivedFields.FormatApptTime(start, null));
|
||
}
|
||
}
|