public void ForEachTestNullCheck() { List <Object> list = null; // ReSharper disable once ReturnValueOfPureMethodIsNotUsed // ReSharper disable once AssignNullToNotNullAttribute Action test = () => IEnumerableTEx.ForEach(list, Console.WriteLine); test.ShouldThrow <ArgumentNullException>(); }
public void ForEachTest1() { var list = RandomValueEx.GetRandomStrings(10); // ReSharper disable once ReturnValueOfPureMethodIsNotUsed Action test = () => IEnumerableTEx.ForEach(list, x => list.Remove(x)); test.ShouldThrow <InvalidOperationException>(); }
public void ForEachTestNullCheck1() { Action <Object> action = null; // ReSharper disable once ReturnValueOfPureMethodIsNotUsed // ReSharper disable once AssignNullToNotNullAttribute Action test = () => IEnumerableTEx.ForEach(new List <Object>(), action); test.ShouldThrow <ArgumentNullException>(); }
public void ForEachTest2() { var list = RandomValueEx.GetRandomStrings(10); var otherList = new List <String>(); var actual = IEnumerableTEx.ForEach(list, otherList.Add); Assert.Same(list, actual); Assert.Equal(list.Count, otherList.Count); Assert.True(list.All(otherList.Contains)); }