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); } }