public void WeightedAverageConstructorCalculatesWeightsSumCorrectlyTest() { int iWindowSize = 6; double[] iWeights = { 1, 2, 3, 4, 5, 6 }; WeightedAveragePreprocessor target = new WeightedAveragePreprocessor(iWindowSize, iWeights); Assert.AreEqual(1 + 2 + 3 + 4 + 5 + 6, target.WeightsSum); target = new WeightedAveragePreprocessor(10); Assert.AreEqual(10, target.WeightsSum); target = new WeightedAveragePreprocessor(); Assert.AreEqual(5, target.WeightsSum); }
public void ProcessTest() { WeightedAveragePreprocessor target = new WeightedAveragePreprocessor(4, new double[] {1, 2, 3, 4}); double[] iArray = {1, 3, 8, 5, 2, 2, 9, 4, 6}; double[] expected = {5.1, 4.2, 3.2, 5.1, 4.9, 5.6}; BSDataObject actual = target.Process(new BSDataObject(iArray)); CheckTwoOrderedArrays(actual.DataArray, expected); target = new WeightedAveragePreprocessor(); iArray = new double[] {1, 2, 3, 4, 5, 6, 7}; expected = new double[] { 3, 4, 5 }; actual = target.Process(new BSDataObject(iArray)); CheckTwoOrderedArrays(actual.DataArray, expected); }
public void WeightedAverageConstructorGeneralTest() { int iWindowSize = 6; double[] iWeights = { 1, 2, 3, 4, 5, 6 }; WeightedAveragePreprocessor target = new WeightedAveragePreprocessor(iWindowSize, iWeights); FieldInfo info = target.GetType().GetField("weights", BindingFlags.Instance | BindingFlags.NonPublic); CheckTwoOrderedArrays((double[])info.GetValue(target), iWeights); target = new WeightedAveragePreprocessor(10); info = target.GetType().GetField("weights", BindingFlags.Instance | BindingFlags.NonPublic); CheckTwoOrderedArrays((double[])info.GetValue(target), new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); }