public void SelectListOperator(string type) { ListOperator enumValue = Enum.Parse <ListOperator>(type); DataModelConditionList.ListOperator = enumValue; NotifyOfPropertyChange(nameof(SelectedListOperator)); _profileEditorService.UpdateSelectedProfileElement(); }
public static List <double> ListDoubleOperation(ListOperator pOperator, params List <double>[] args) { List <double> outputList = (new List <double>()); int[] arglengths = args.Select(x => x.Count).ToArray(); double[] argAt; int i, j; double opValue; if (arglengths.Max() == arglengths.Min()) { for (i = 0; i < args[0].Count; i++) { argAt = args.Select(x => x[i]).ToArray(); opValue = 0; switch (pOperator) { case ListOperator.SUM: for (j = 0; j < argAt.Length; j++) { opValue += argAt[j]; } break; case ListOperator.DIFF: opValue = argAt[0]; for (j = 1; j < argAt.Length; j++) { opValue -= argAt[j]; } break; case ListOperator.MULTIPLY: for (j = 0; j < argAt.Length; j++) { opValue *= argAt[j]; } break; case ListOperator.DIVIDE: opValue = argAt[0]; for (j = 1; j < argAt.Length; j++) { opValue /= argAt[j]; } break; default: break; } outputList.Add(Math.Round(opValue, 4)); } } return(outputList); }
public void TestLengthBiggerThanCount() { List <int> ls1 = new List <int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); List <int> ls2 = ListOperator <int> .SubList(ls1, 3, 11); List <int> ls3 = new List <int>(new int[] { 4, 5, 6, 7, 8, 9, 10 }); Assert.AreEqual(ListOperator <int> .ValueEqual(ls3, ls2), true); }
public void TestNormal() { List <int> ls1 = new List <int>(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }); List <int> ls2 = ListOperator <int> .SubList(ls1, 3, 7); List <int> ls3 = new List <int>(new int[] { 4, 5, 6, 7, 8 }); Assert.AreEqual(ListOperator <int> .ValueEqual(ls3, ls2), true); }
public void TestSameValueAreEqual() { List <int> ls1 = new List <int>(new int[] { 1, 2, 3, 4, 5, 6 }); List <int> ls2 = new List <int>(new int[] { 1, 2, 3, 4, 5, 6 }); bool expected = true; bool actual = ListOperator <int> .ValueEqual(ls1, ls2); Assert.AreEqual(expected, actual); }
public void TestDoubleEmpty() { List <int> ls1 = new List <int>(); List <int> ls2 = new List <int>(); bool expected = true; bool actual = ListOperator <int> .ValueEqual(ls1, ls2); Assert.AreEqual(expected, actual); }
public void TestDiffLengthAreEqual() { List <int> ls1 = new List <int>(new int[] { 1, 2, 3, 4, 5, 6 }); List <int> ls2 = new List <int>(new int[] { 1, 2, 3, 4, 5 }); bool expected = false; bool actual = ListOperator <int> .ValueEqual(ls1, ls2); Assert.AreEqual(expected, actual); }
public void TestDoubleSameValueAreEqual() { List <double> ls1 = new List <double>(new double[] { 1.00001, 2, 3, 4, 5, 6 }); List <double> ls2 = new List <double>(new double[] { 1.00001, 2, 3, 4, 5, 6 }); bool expected = true; bool actual = ListOperator <double> .ValueEqual(ls1, ls2); Assert.AreEqual(expected, actual); }
public void TestSingleNull() { List <int> ls1 = null; List <int> ls2 = new List <int>(new int[] { 1, 2, 3, 4, 5 }); bool expected = false; bool actual = ListOperator <int> .ValueEqual(ls1, ls2); Assert.AreEqual(expected, actual); ls1 = new List <int>(); ls2 = null; Assert.AreEqual(ListOperator <int> .ValueEqual(ls1, ls2), false); }