public void ValueTest() { LinearInterpolator target = new LinearInterpolator(); // Create the point to interpolate for IPoint point = new Point1D(4, 0); // Create the bounding points List <IPoint> bounds = new List <IPoint> { new Point1D(2, 5), new Point1D(6, 13) }; // Set the expected value double expected = 9; // Interpolate and test result double actual = target.Value(point, bounds); Assert.AreEqual(expected, actual); // Create the point to interpolate for point = new Point1D(11, 0); // Create the bounding points bounds = new List <IPoint> { new Point1D(10, 21), new Point1D(12, 25) }; // Set the expected value expected = 23; // Interpolate and test result actual = target.Value(point, bounds); Assert.AreEqual(expected, actual); // Create the point to interpolate for point = new Point1D(11, 0); // Create the bounding points bounds = new List <IPoint> { new Point1D(6, 13), new Point1D(13, 27) }; // Set the expected value expected = 23; // Interpolate and test result actual = target.Value(point, bounds); Assert.AreEqual(expected, actual); // Test boundary condition x<x1<x2 // Create the point to interpolate for point = new Point1D(1, 0); // Create the bounding points bounds = new List <IPoint> { new Point1D(2, 5), new Point1D(4, 9) }; // Set the expected value expected = 5.0d; // Interpolate and test result actual = target.Value(point, bounds); Assert.AreEqual(expected, actual); // Test boundary condition x1<x2<x // Create the point to interpolate for point = new Point1D(12); // Create the bounding points bounds = new List <IPoint> { new Point1D(8, 17), new Point1D(10, 21) }; // Set the expected value expected = 21.0d; // Interpolate and test result actual = target.Value(point, bounds); Assert.AreEqual(expected, actual); }