mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 09:33:13 +00:00
53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using Data.SeaHavenIndustries;
|
||
using SeaHaven.Services.Helpers;
|
||
|
||
namespace SeaHavenIndustries.Tests;
|
||
|
||
public class WorkOrderBoardFieldMutationsTests
|
||
{
|
||
[Fact]
|
||
public void ApplyApptTime_EmptyValue_ClearsStartAndEnd_KeepsDates()
|
||
{
|
||
var appointmentDate = new DateTime(2026, 6, 25);
|
||
var workOrder = new WorkOrder
|
||
{
|
||
ScheduledDate = appointmentDate,
|
||
ScheduledStart = new DateTime(2026, 6, 25, 9, 0, 0),
|
||
ScheduledEnd = new DateTime(2026, 6, 25, 11, 0, 0)
|
||
};
|
||
var dispatch = new Dispatch { Id = 10, ScheduledDate = appointmentDate };
|
||
|
||
WorkOrderBoardFieldMutations.ApplyApptTime(workOrder, dispatch, "");
|
||
|
||
Assert.Null(workOrder.ScheduledStart);
|
||
Assert.Null(workOrder.ScheduledEnd);
|
||
Assert.Equal(appointmentDate, workOrder.ScheduledDate);
|
||
Assert.Equal(appointmentDate, dispatch.ScheduledDate);
|
||
}
|
||
|
||
[Fact]
|
||
public void ApplyApptTime_StartOnly_LeavesEndNull()
|
||
{
|
||
var appointmentDate = new DateTime(2026, 6, 25);
|
||
var workOrder = new WorkOrder { ScheduledDate = appointmentDate };
|
||
var dispatch = new Dispatch { Id = 10, ScheduledDate = appointmentDate };
|
||
|
||
WorkOrderBoardFieldMutations.ApplyApptTime(workOrder, dispatch, "09:00");
|
||
|
||
Assert.Equal(new DateTime(2026, 6, 25, 9, 0, 0), workOrder.ScheduledStart);
|
||
Assert.Null(workOrder.ScheduledEnd);
|
||
}
|
||
|
||
[Fact]
|
||
public void ApplyApptTime_Range_SetsStartAndEnd()
|
||
{
|
||
var appointmentDate = new DateTime(2026, 6, 25);
|
||
var workOrder = new WorkOrder { ScheduledDate = appointmentDate };
|
||
var dispatch = new Dispatch { Id = 10, ScheduledDate = appointmentDate };
|
||
|
||
WorkOrderBoardFieldMutations.ApplyApptTime(workOrder, dispatch, "09:00 – 11:00");
|
||
|
||
Assert.Equal(new DateTime(2026, 6, 25, 9, 0, 0), workOrder.ScheduledStart);
|
||
Assert.Equal(new DateTime(2026, 6, 25, 11, 0, 0), workOrder.ScheduledEnd);
|
||
}
|
||
}
|