public void Find_VerifyDuplicates(int count) { T?expectedItem = default(T); SegmentedList <T> list = GenericListFactory(count); SegmentedList <T> beforeList = list.ToSegmentedList(); T?foundItem; Predicate <T?> EqualsDelegate = (T? item) => { return(expectedItem == null ? item == null : expectedItem.Equals(item)); }; if (0 < count) { list.Add(beforeList[0]); //[] Verify first item is duplicated expectedItem = beforeList[0]; foundItem = list.Find(EqualsDelegate); Assert.Equal(expectedItem, foundItem); //"Err_2879072qaiadf Verify first item is duplicated FAILED\n" } if (1 < count) { list.Add(beforeList[1]); //[] Verify second item is duplicated expectedItem = beforeList[1]; foundItem = list.Find(EqualsDelegate); Assert.Equal(expectedItem, foundItem); //"Err_4588ajdia Verify second item is duplicated FAILED\n" //[] Verify with match that matches more then one item expectedItem = beforeList[0]; foundItem = list.Find(EqualsDelegate); Assert.Equal(expectedItem, foundItem); //"Err_4489ajodoi Verify with match that matches more then one item FAILED\n" } }
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); }