private void Exists_VerifyVanilla(T[] items) { T?expectedItem = default(T); SegmentedList <T?> list = new SegmentedList <T?>(); Predicate <T?> 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(T)); Assert.True(list.Exists((T? item) => { return(item == null ? default(T) == null : item.Equals(default(T))); }), "Err_541848ajodi Verify with default(T) FAILED\n"); list.RemoveAt(list.Count - 1); }
public void Find_VerifyVanilla(int count) { SegmentedList <T?> list = GenericListFactory(count) !; SegmentedList <T?> beforeList = list.ToSegmentedList(); T?expectedItem = default(T); T?foundItem; Predicate <T?> EqualsDelegate = (T? item) => { return(expectedItem == null ? item == null : expectedItem.Equals(item)); }; //[] Verify Find returns the correct index for (int i = 0; i < count; ++i) { expectedItem = beforeList[i]; foundItem = list.Find(EqualsDelegate); Assert.Equal(expectedItem, foundItem); //"Err_282308ahid Verifying value returned from Find FAILED\n" } //[] Verify Find returns the first item if the match returns true on every item foundItem = list.Find(_alwaysTrueDelegate); Assert.Equal(0 < count ? beforeList[0] : default(T), foundItem); //"Err_548ahid Verify Find returns the first item if the match returns true on every item FAILED\n" //[] Verify Find returns T.Default if the match returns false on every item foundItem = list.Find(_alwaysFalseDelegate); Assert.Equal(default(T), foundItem); //"Err_30848ahidi Verify Find returns T.Default if the match returns false on every item FAILED\n" //[] Verify with default(T) list.Add(default(T)); foundItem = list.Find((T? item) => { return(item == null ? default(T) == null : item.Equals(default(T))); }); Assert.Equal(default(T), foundItem); //"Err_541848ajodi Verify with default(T) FAILED\n" list.RemoveAt(list.Count - 1); }