public void Exists_VerifyExceptions(T[] items) { using (var list = new PooledList <T>()) { for (int i = 0; i < items.Length; ++i) { list.Add(items[i]); } //[] Verify Null match Assert.Throws <ArgumentNullException>(() => list.Exists(null)); //"Err_858ahia Expected null match to throw ArgumentNullException" } }
private void Exists_VerifyVanilla(T[] items) { T expectedItem = default; using (var list = new PooledList <T>()) { bool expectedItemDelegate(T item) { return(expectedItem == null ? item == null : expectedItem.Equals(item)); } bool typeNullable = default(T) == null; for (int i = 0; i < items.Length; ++i) { list.Add(items[i]); } //[] Verify Exists returns the correct index for (int i = 0; i < items.Length; ++i) { expectedItem = items[i]; Assert.True(list.Exists(expectedItemDelegate), "Err_282308ahid Verifying Nullable returned FAILED\n"); } //[] Verify Exists returns true if the match returns true on every item Assert.True((0 < items.Length) == list.Exists((T item) => { return(true); }), "Err_548ahid Verify Exists returns 0 if the match returns true on every item FAILED\n"); //[] Verify Exists returns false if the match returns false on every item Assert.True(!list.Exists((T item) => { return(false); }), "Err_30848ahidi Verify Exists returns -1 if the match returns false on every item FAILED\n"); //[] Verify with default(T) list.Add(default);