public void TakeWhileWithIndex() { var ints = new[] { 1, 2, 3, 4, 5 }.TakeWhile((x, i) => i < 3).ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 1); QUnit.AreEqual(ints[1], 2); QUnit.AreEqual(ints[2], 3); }
public void ElementAtOrDefault() { var items = new[] { 0, 1, 2 }; QUnit.AreEqual(items.ElementAtOrDefault(0), 0); QUnit.AreEqual(items.ElementAtOrDefault(1), 1); QUnit.AreEqual(items.ElementAtOrDefault(2), 2); QUnit.AreEqual(items.ElementAtOrDefault(3), 0); }
public void SkipWhile() { var ints = new[] { 1, 2, 3, 4, 5 }.SkipWhile(x => x < 3).ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 3); QUnit.AreEqual(ints[1], 4); QUnit.AreEqual(ints[2], 5); }
public void Take() { var ints = new[] { 8, 3, 5, 1 }.Take(3).ToArray(); QUnit.AreEqual(ints.Length, 3); QUnit.AreEqual(ints[0], 8); QUnit.AreEqual(ints[1], 3); QUnit.AreEqual(ints[2], 5); }
public void SelectWithIndex() { var array = new[] { "1", "2", "3" }; var two = array.Select((x, i) => x + "a" + i).ToArray(); QUnit.AreEqual(two[0], "1a0"); QUnit.AreEqual(two[1], "2a1"); QUnit.AreEqual(two[2], "3a2"); }
public void DupsDontChangeCount() { var dictionary = new Dictionary <string, int>(); dictionary["one"] = 1; dictionary["one"] = 2; QUnit.AreEqual(dictionary["one"], 2); QUnit.AreEqual(dictionary.Count, 1); }
public void Set() { var dictionary = new Dictionary <string, int>(); dictionary["one"] = 1; dictionary["two"] = 2; QUnit.AreEqual(dictionary["one"], 1); QUnit.AreEqual(dictionary["two"], 2); }
public void Property() { Expression <Func <ClassWithMembers, string> > lambda = x => x.StringProperty; var memberExpression = (MemberExpression)lambda.Body; QUnit.AreEqual(memberExpression.Expression, lambda.Parameters[0]); QUnit.IsTrue(memberExpression.Member is PropertyInfo); QUnit.AreEqual(memberExpression.Member.Name, "StringProperty"); }
public void DefaultIfEmptyExplicitDefault() { var s = new string[0].DefaultIfEmpty("default").Single(); QUnit.AreEqual(s, "default"); var i = new int[0].DefaultIfEmpty(5).Single(); QUnit.AreEqual(i, 5); }
public void DefaultIfEmpty() { var s = new string[0].DefaultIfEmpty().Single(); QUnit.AreEqual(s, null); var i = new int[0].DefaultIfEmpty().Single(); QUnit.AreEqual(i, 0); }
public void Reverse() { var ints = new[] { 1, 2, 3 }; var reverse = ints.Reverse().ToArray(); QUnit.AreEqual(reverse.Length, 3); QUnit.AreEqual(reverse[0], 3); QUnit.AreEqual(reverse[1], 2); QUnit.AreEqual(reverse[2], 1); }