using System; using DevilLink2.UI; using NUnit.Framework; namespace DevilLink2.Tests { public sealed class ScreenLayoutTests { [TestCase(430,932)] [TestCase(320,568)] [TestCase(390,760)] [TestCase(1125,2202)] [TestCase(932,430)] [TestCase(200,300)] public void UniformFitKeepsEveryDesignControlInsideAvailableSafeRectangle(float width,float height) { float scale=ScreenLayout.FitScale(width,height); Assert.That(430*scale,Is.LessThanOrEqualTo(width+.001)); Assert.That(932*scale,Is.LessThanOrEqualTo(height+.001)); Assert.That(430*scale/(932*scale),Is.EqualTo(430f/932).Within(.00001)); Assert.That((932*.7f+56)*scale,Is.LessThanOrEqualTo(height)); } [Test] public void FinalCssUsesThreeVerticalCardsBetweenHudAndDock() { Assert.That(ScreenLayout.CardHeight,Is.EqualTo(252.66667f).Within(.001)); for(int i=0;i<3;i++) { Assert.That(ScreenLayout.CardTop(i),Is.GreaterThanOrEqualTo(56)); Assert.That(ScreenLayout.CardTop(i)+ScreenLayout.CardHeight,Is.LessThanOrEqualTo(850)); if(i<2)Assert.That(ScreenLayout.CardTop(i+1)-ScreenLayout.CardTop(i)-ScreenLayout.CardHeight,Is.EqualTo(8).Within(.001)); } } [Test] public void InvalidAvailableSizeIsRejected() { Assert.Throws(()=>ScreenLayout.FitScale(-1,100)); Assert.Throws(()=>ScreenLayout.FitScale(float.NaN,100)); Assert.Throws(()=>ScreenLayout.FitScale(100,float.PositiveInfinity)); } } }