1.3 Orientation value type
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
46
tests/FrameProcessor.Tests/OrientationTests.cs
Normal file
46
tests/FrameProcessor.Tests/OrientationTests.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Text.Json;
|
||||
using FrameProcessor.Domain;
|
||||
|
||||
namespace FrameProcessor.Tests;
|
||||
|
||||
public class OrientationTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("\"landscape\"", Orientation.Landscape)]
|
||||
[InlineData("\"portrait\"", Orientation.Portrait)]
|
||||
public void JsonDeserialize_KebabCaseLowercase(string json, Orientation expected)
|
||||
{
|
||||
var value = JsonSerializer.Deserialize<Orientation>(json);
|
||||
Assert.Equal(expected, value);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(Orientation.Landscape, "\"landscape\"")]
|
||||
[InlineData(Orientation.Portrait, "\"portrait\"")]
|
||||
public void JsonSerialize_KebabCaseLowercase(Orientation value, string expected)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(value);
|
||||
Assert.Equal(expected, json);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("\"Landscape\"")]
|
||||
[InlineData("\"PORTRAIT\"")]
|
||||
[InlineData("\"diagonal\"")]
|
||||
[InlineData("\"\"")]
|
||||
public void JsonDeserialize_RejectsInvalid(string json)
|
||||
{
|
||||
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<Orientation>(json));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonRoundTrip_PreservesValue()
|
||||
{
|
||||
foreach (var value in new[] { Orientation.Landscape, Orientation.Portrait })
|
||||
{
|
||||
var json = JsonSerializer.Serialize(value);
|
||||
var roundTripped = JsonSerializer.Deserialize<Orientation>(json);
|
||||
Assert.Equal(value, roundTripped);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user