Exemple #1
0
        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>();
        }
Exemple #2
0
        public void ForEachTest1()
        {
            var list = RandomValueEx.GetRandomStrings(10);

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            Action test = () => IEnumerableTEx.ForEach(list, x => list.Remove(x));

            test.ShouldThrow <InvalidOperationException>();
        }
Exemple #3
0
        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>();
        }
Exemple #4
0
        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));
        }