using NUnit.Framework; namespace Chernobyl.Utility { [TestFixture, Description("Tests for the ComparableExtensions type.")] public class ComparableExtensionsTests { [Test, Description("A test that ensures the ComparableExtensions.Clamp(T, T, T) " + "method can clamp to the minimum value.")] public void ClampToMin() { float x = -0.1f; x = x.Clamp(0, 1); Assert.AreEqual(0f, x, "The value was not clamped to the minimum value."); } [Test, Description("A test that ensures the ComparableExtensions.Clamp(T, T, T) " + "method does not clamp when it is not necessary.")] public void NoClamp() { const float expected = 0.5f; float x = expected.Clamp(0, 1); Assert.AreEqual(expected, x, "The value was modified when it should not have been."); } [Test, Description("A test that ensures the ComparableExtensions.Clamp(T, T, T) " + "method can clamp to the maximum value.")] public void ClampToMax() { float x = 1.1f; x = x.Clamp(0, 1); Assert.AreEqual(1f, x, "The value was not clamped to the maximum value."); } } }