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); }
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); }
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); }