Initial Commit
This commit is contained in:
commit
86fc06b877
37 changed files with 3424 additions and 0 deletions
40
tests/Decky.Core.Tests/CardUpdateRequestTests.cs
Normal file
40
tests/Decky.Core.Tests/CardUpdateRequestTests.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System.Text.Json;
|
||||
using Decky.Core.Api.Models;
|
||||
using Decky.Core.Api.Requests;
|
||||
|
||||
namespace Decky.Core.Tests;
|
||||
|
||||
public sealed class CardUpdateRequestTests
|
||||
{
|
||||
[Fact]
|
||||
public void FromCard_preserves_fields_and_serializes_explicit_null_done()
|
||||
{
|
||||
var card = new CardDto
|
||||
{
|
||||
Id = 7,
|
||||
StackId = 3,
|
||||
Title = "Original",
|
||||
Description = "Details",
|
||||
Type = "plain",
|
||||
Owner = "elijah",
|
||||
Order = 42,
|
||||
Archived = false,
|
||||
Done = DateTimeOffset.Parse("2026-07-19T12:00:00Z"),
|
||||
DueDate = DateTimeOffset.Parse("2026-07-20T12:00:00Z"),
|
||||
StartDate = DateTimeOffset.Parse("2026-07-18T12:00:00Z"),
|
||||
Color = "d99080",
|
||||
};
|
||||
|
||||
var request = CardUpdateRequest.FromCard(card, title: "Changed", done: null, replaceDone: true);
|
||||
var json = JsonSerializer.Serialize(request, new JsonSerializerOptions(JsonSerializerDefaults.Web));
|
||||
using var document = JsonDocument.Parse(json);
|
||||
var root = document.RootElement;
|
||||
|
||||
Assert.Equal("Changed", root.GetProperty("title").GetString());
|
||||
Assert.Equal("elijah", root.GetProperty("owner").GetString());
|
||||
Assert.Equal("D99080", root.GetProperty("color").GetString());
|
||||
Assert.Equal("2026-07-20T12:00:00+00:00", root.GetProperty("duedate").GetString());
|
||||
Assert.Equal(JsonValueKind.Null, root.GetProperty("done").ValueKind);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue