Example #1
0
        public void TestSelectWhenDoesntExists()
        {
            string[] strings =
            { "Ana",
              "Andrei",
              "Sabin",
              "Alin",
              "Mihai" };

            Func <string, bool> myFunc = (x) => x.StartsWith("gf", StringComparison.InvariantCultureIgnoreCase) ? true : false;

            var results = LinqFunctions.Select(strings, p => myFunc(p));

            var matches = 0;

            foreach (var result in results)
            {
                if (result)
                {
                    matches++;
                }
            }

            Assert.Equal(0, matches);
        }
Example #2
0
        public void TestSelectWhenNullSource()
        {
            string[] strings = null;

            Func <string, int> myFunc = x => x.Length;

            var p = myFunc;

            var results = LinqFunctions.Select(strings, p);

            var numerator = results.GetEnumerator();

            var msg = Assert.Throws <ArgumentNullException>(() => numerator.MoveNext());

            Assert.Equal("source", msg.ParamName);
        }
Example #3
0
        public void TestSelectWhenNullSelector()
        {
            string[] strings =
            { "Ana",
              "Andrei",
              "Sabin",
              "Alin",
              "Mihai" };

            Func <string, int> myFunc = null;

            var p = myFunc;

            var results = LinqFunctions.Select(strings, p);

            var numerator = results.GetEnumerator();

            var msg = Assert.Throws <ArgumentNullException>(() => numerator.MoveNext());

            Assert.Equal("selector", msg.ParamName);
        }