mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
46 lines
2 KiB
C#
46 lines
2 KiB
C#
using SeaHaven.Services.Helpers;
|
|
using Xunit;
|
|
|
|
namespace SeaHaven.Services.Tests;
|
|
|
|
public sealed class WorkOrderExternalVersionTests
|
|
{
|
|
[Fact]
|
|
public void Work_order_inputs_from_webhook_and_reconciliation_have_the_same_canonical_hash()
|
|
{
|
|
var timestamp = DateTimeOffset.Parse("2026-07-24T12:00:00+02:00");
|
|
var webhook = new WorkOrderExternalVersion.WorkOrder(
|
|
"42", "new", "Leaking pipe", "Acme", "S1", "A", "1 Main St", "2", "High",
|
|
"Alex", timestamp, timestamp.AddHours(1), timestamp.AddDays(1), "update", timestamp,
|
|
"emails/42.eml");
|
|
var reconciliation = webhook with { DateReported = timestamp.ToUniversalTime() };
|
|
|
|
Assert.Equal(
|
|
WorkOrderExternalVersion.ComputeWorkOrder(webhook),
|
|
WorkOrderExternalVersion.ComputeWorkOrder(reconciliation));
|
|
}
|
|
|
|
[Fact]
|
|
public void Comment_inputs_from_webhook_and_reconciliation_have_the_same_20_slot_canonical_hash()
|
|
{
|
|
var createdAt = DateTimeOffset.Parse("2026-07-24T11:59:00+02:00");
|
|
var ingestedAt = DateTimeOffset.Parse("2026-07-24T12:01:00+02:00");
|
|
var webhook = new WorkOrderExternalVersion.Comment(
|
|
"42", "comment-7", "comment", "Alex", "A note", createdAt, ingestedAt, "emails/42.eml");
|
|
var reconciliation = webhook with
|
|
{
|
|
CreatedAt = createdAt.ToUniversalTime(),
|
|
IngestedAt = ingestedAt.ToUniversalTime()
|
|
};
|
|
|
|
Assert.Equal(
|
|
WorkOrderExternalVersion.ComputeComment(webhook),
|
|
WorkOrderExternalVersion.ComputeComment(reconciliation));
|
|
Assert.Equal(
|
|
WorkOrderExternalVersion.Compute(
|
|
"42", null, null, null, null, null, null, null, null, null,
|
|
null, null, null, "comment", "2026-07-24T09:59:00.0000000+00:00", "emails/42.eml", "comment-7", "Alex",
|
|
"A note", "2026-07-24T10:01:00.0000000+00:00"),
|
|
WorkOrderExternalVersion.ComputeComment(webhook));
|
|
}
|
|
}
|