Exemple #1
0
        public void TestFirstWhenDoesntExists()
        {
            var array = new int[] { 2, 5, 3 };

            Func <int, bool> myFunc = (x) => { return(x == 4); };

            var msg = Assert.Throws <InvalidOperationException>(() => LinqFunctions.First(array, p => myFunc(p)));

            Assert.Equal("No element has been found", msg.Message);
        }
Exemple #2
0
        public void TestFirstWhenSourceIsNull()
        {
            int[] array = null;

            Func <int, bool> myFunc = (x) => { return(x == 4); };

            var msg = Assert.Throws <ArgumentNullException>(() => LinqFunctions.First(array, p => myFunc(p)));

            Assert.Equal("Value cannot be null.\r\nParameter name: source", msg.Message);
        }
Exemple #3
0
        public void TestFirstWhenExists()
        {
            var array = new int[] { 1, 2, 3, 4, 5 };

            Func <int, bool> myFunc = (x) => { return(x == 4); };

            var result = LinqFunctions.First(array, p => myFunc(p));

            Assert.Equal(4, result);
        }