public void EveryContainsSome_Every_WhenPassedListOfNumsAndDel_ShouldReturnBool() { // arrange var originalList = new List <int>() { 2, 4, 5 }; bool expected = false; var originalList2 = new List <int>() { 2, 4, 12 }; bool expected2 = true; var x = new EveryContainsSome(); // act // Instantiate the delegate EvaluateInt handler = x.Evaluate; var actual = x.Every(originalList, handler); var actual2 = x.Every(originalList2, handler); // assert Assert.Equal(expected, actual); Assert.Equal(expected2, actual2); }
public bool Every(List <int> intList, EvaluateInt evaluate) { bool result = true; foreach (int item in intList) { bool outcome = Evaluate(item); if (outcome == false) { result = false; break; } } return(result); }