Files
mrgameeng/tests/MrGameEng.Graphics.Tests/SortKeyTests.cs
T
Leonid Pershin fd6343bd09
CI / build-test (push) Failing after 1m8s
@
Add MrGameEng.AI utility-AI module; format codebase with CSharpier

New MrGameEng.AI module (ResponseCurve, Consideration, UtilityAction,
UtilityAi selector, Blackboard) plus CSharpier formatting applied across
the whole engine. Documents the CSharpier convention in CLAUDE.md.
@
2026-06-12 07:19:10 +03:00

50 lines
1.3 KiB
C#

using MrGameEng.Graphics;
using Xunit;
namespace MrGameEng.Graphics.Tests;
public class SortKeyTests
{
[Fact]
public void LayerDominatesDepthAndTexture()
{
var lowLayer = SpriteSortKey.Make(0, 1000f, textureKey: 5);
var highLayer = SpriteSortKey.Make(1, -1000f, textureKey: 1);
Assert.True(lowLayer < highLayer);
}
[Fact]
public void DepthDominatesTexture_WithinLayer()
{
var behind = SpriteSortKey.Make(3, -5f, textureKey: 999);
var inFront = SpriteSortKey.Make(3, 5f, textureKey: 1);
Assert.True(behind < inFront);
}
[Theory]
[InlineData(-100f, -1f)]
[InlineData(-1f, 0f)]
[InlineData(0f, 1f)]
[InlineData(1f, 100f)]
[InlineData(-0.5f, 0.5f)]
public void DepthBits_PreserveFloatOrder(float smaller, float larger)
{
Assert.True(
SpriteSortKey.DepthToSortableBits(smaller) < SpriteSortKey.DepthToSortableBits(larger)
);
}
[Fact]
public void EqualLayerAndDepth_GroupByTexture()
{
var a1 = SpriteSortKey.Make(2, 1f, textureKey: 7);
var b = SpriteSortKey.Make(2, 1f, textureKey: 9);
var a2 = SpriteSortKey.Make(2, 1f, textureKey: 7);
Assert.Equal(a1, a2);
Assert.NotEqual(a1, b);
}
}