public void AddIfNew_Returns_Empty_If_Item_Is_Null_Or_Whitespace_And_Baselist_Is_Null(string checkItem) { IEnumerable <string> updatedList = ListLibrary.AddIfNew(null, checkItem); List <string> result = new List <string>(updatedList); Assert.AreEqual(0, result.Count); }
public void AddIfNew_Returns_List_Of_Only_Checked_Item_If_BaseList_Is_Null() { string checkItem = "Fie"; IEnumerable <string> updatedList = ListLibrary.AddIfNew(null, checkItem); List <string> result = new List <string>(updatedList); List <string> expectedResult = new List <string>() { "Fie" }; Assert.AreEqual(1, result.Count); Assert.AreEqual(expectedResult[0], result[0]); }
public void AddIfNew_Returns_Original_If_Item_Is_Null_Or_Whitespace(string checkItem) { Collection <string> baseList = new Collection <string>() { "Foo", "Bar", "Moo", "Nar" }; IEnumerable <string> updatedList = ListLibrary.AddIfNew(baseList, checkItem); List <string> result = new List <string>(updatedList); List <string> expectedResult = new List <string>() { "Foo", "Bar", "Moo", "Nar" }; Assert.AreEqual(expectedResult.Count, result.Count); Assert.AreEqual(expectedResult[0], result[0]); Assert.AreEqual(expectedResult[1], result[1]); Assert.AreEqual(expectedResult[2], result[2]); Assert.AreEqual(expectedResult[3], result[3]); }
public void AddIfNew_Ignores_New_If_Not_Unique_Considering_Case() { Collection <string> baseList = new Collection <string>() { "Foo", "Bar", "Moo", "Nar" }; string checkItem = "bar"; IEnumerable <string> updatedList = ListLibrary.AddIfNew(baseList, checkItem, caseSensitive: false); List <string> result = new List <string>(updatedList); List <string> expectedResult = new List <string>() { "Foo", "Bar", "Moo", "Nar" }; Assert.AreEqual(expectedResult.Count, result.Count); Assert.AreEqual(expectedResult[0], result[0]); Assert.AreEqual(expectedResult[1], result[1]); Assert.AreEqual(expectedResult[2], result[2]); Assert.AreEqual(expectedResult[3], result[3]); }
public void AddIfNew_Preppends_New_If_Unique_And_Place_First_Is_Specified() { Collection <string> baseList = new Collection <string>() { "Foo", "Bar", "Moo", "Nar" }; string checkItem = "Fie"; IEnumerable <string> updatedList = ListLibrary.AddIfNew(baseList, checkItem, placeFirst: true); List <string> result = new List <string>(updatedList); List <string> expectedResult = new List <string>() { "Fie", "Foo", "Bar", "Moo", "Nar" }; Assert.AreEqual(expectedResult.Count, result.Count); Assert.AreEqual(expectedResult[0], result[0]); Assert.AreEqual(expectedResult[1], result[1]); Assert.AreEqual(expectedResult[2], result[2]); Assert.AreEqual(expectedResult[3], result[3]); Assert.AreEqual(expectedResult[4], result[4]); }
public void AddIfNew_Appends_New_If_Unique_By_Default() { Collection <string> baseList = new Collection <string>() { "Foo", "Bar", "Moo", "Nar" }; string checkItem = "Fie"; IEnumerable <string> updatedList = ListLibrary.AddIfNew(baseList, checkItem); List <string> result = new List <string>(updatedList); List <string> expectedResult = new List <string>() { "Foo", "Bar", "Moo", "Nar", "Fie" }; Assert.AreEqual(expectedResult.Count, result.Count); Assert.AreEqual(expectedResult[0], result[0]); Assert.AreEqual(expectedResult[1], result[1]); Assert.AreEqual(expectedResult[2], result[2]); Assert.AreEqual(expectedResult[3], result[3]); Assert.AreEqual(expectedResult[4], result[4]); }