fix: Begin rewriting RangeAttribute

This commit is contained in:
Chris Cameron
2019-06-12 23:42:59 -04:00
parent 6526b2b811
commit e3273934a7
4 changed files with 359 additions and 246 deletions

View File

@@ -27,6 +27,10 @@ namespace ICD.Common.Utils.Tests
[Test, UsedImplicitly]
public void MapRangeTest()
{
Assert.AreEqual(5, MathUtils.MapRange(-100, 100, 0, 10, 0));
Assert.AreEqual(7, MathUtils.MapRange(-100, 100, 0, 10, 50));
Assert.AreEqual(10, MathUtils.MapRange(-100, 100, 0, 10, 100));
Assert.AreEqual(0, MathUtils.MapRange(0, 100, 0, 10, 0));
Assert.AreEqual(5, MathUtils.MapRange(0, 100, 0, 10, 50));
Assert.AreEqual(10, MathUtils.MapRange(0, 100, 0, 10, 100));
@@ -36,7 +40,13 @@ namespace ICD.Common.Utils.Tests
Assert.AreEqual(100, MathUtils.MapRange(0, 10, 0, 100, 10));
}
[Test, UsedImplicitly]
[TestCase(double.MinValue, double.MaxValue, 0.0, 1.0, double.MaxValue, 1.0)]
public void MapRangeTest(double inputStart, double inputEnd, double outputStart, double outputEnd, double value, double expected)
{
Assert.AreEqual(expected, MathUtils.MapRange(inputStart, inputEnd, outputStart, outputEnd, value));
}
[Test, UsedImplicitly]
public void GetRangesTest()
{
IEnumerable<int> values = new [] { 1, 3, 5, 6, 7, 8, 9, 10, 12 };