// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) James South. // Licensed under the Apache License, Version 2.0. // // // Runs unit tests on the extension methods // // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.UnitTests.Extensions { using System.Collections.Generic; using Common.Extensions; using NUnit.Framework; /// /// Test harness for the DoubleExtensions extension methods /// [TestFixture] public class DoubleExtensionsUnitTests { /// /// Stores the values to test for the ToByte() extension method /// private Dictionary doubleToByteTests; /// /// Sets up the values for the tests /// [TestFixtureSetUp] public void Init() { this.doubleToByteTests = new Dictionary { { -10, 0x0 }, { 1.5, 0x1 }, { 25.7, 0x19 }, { 1289047, 0xFF } }; } /// /// Tests the double to byte conversion /// [Test] public void TestDoubleToByte() { foreach (var item in this.doubleToByteTests) { var result = item.Key.ToByte(); Assert.AreEqual(item.Value, result); } } } }