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 AppendToList_Returns_Appended_List()
        {
            Collection <string> originalList = new Collection <string>()
            {
                "Roo", "Rar", "Soo", "Car"
            };
            Collection <string> listToAppend = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };
            Collection <string> expectedResult = new Collection <string>()
            {
                "Roo", "Rar", "Soo", "Car", "Foo", "Bar", "Moo", "Nar"
            };

            List <string> appendedList = new List <string>(ListLibrary.AppendToList(originalList, listToAppend));

            Assert.IsTrue(appendedList.Count == listToAppend.Count + originalList.Count);
            Assert.AreEqual(expectedResult[0], appendedList[0]);
            Assert.AreEqual(expectedResult[1], appendedList[1]);
            Assert.AreEqual(expectedResult[2], appendedList[2]);
            Assert.AreEqual(expectedResult[3], appendedList[3]);
            Assert.AreEqual(expectedResult[4], appendedList[4]);
            Assert.AreEqual(expectedResult[5], appendedList[5]);
            Assert.AreEqual(expectedResult[6], appendedList[6]);
            Assert.AreEqual(expectedResult[7], appendedList[7]);
        }
        public void SortCorrelatedLists_With_Jagged_Correlated_Lists_Throws_Exception()
        {
            var ex = Assert.Throws <IndexOutOfRangeException>(() =>
            {
                IList <string> listToSort = new List <string>()
                {
                    "2", "4", "1", "3"
                };

                IList <IList <string> > correlatedLists = new List <IList <string> >();
                List <string> list1 = new List <string>()
                {
                    "One", "Two"
                };
                List <string> list2 = new List <string>()
                {
                    "Four", "One", "Two", "Three", "Foo"
                };
                List <string> list3 = new List <string>()
                {
                    "Three", "Four", "One", "Two"
                };
                correlatedLists.Add(list1);
                correlatedLists.Add(list2);
                correlatedLists.Add(list3);

                ListLibrary.SortCorrelatedLists(ref listToSort, ref correlatedLists, sortAscending: true);
            });

            Assert.That(ex.Message, Is.EqualTo("Method cannot correlate sorting of jagged lists! \r\nMake sure all lists provided are of equal length to each other and the primary list being sorted."));
        }
        public void CombineListsUnique_Returns_Appended_List_If_Both_Lists_Are_Unique()
        {
            Collection <string> originalList = new Collection <string>()
            {
                "Roo", "Rar", "Soo", "Car"
            };
            Collection <string> newList = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };
            Collection <string> expectedResult = new Collection <string>()
            {
                "Roo", "Rar", "Soo", "Car", "Foo", "Bar", "Moo", "Nar"
            };

            List <string> appendedList = new List <string>(ListLibrary.CombineListsUnique(originalList, newList));

            Assert.IsTrue(appendedList.Count == newList.Count + originalList.Count);
            Assert.AreEqual(expectedResult[0], appendedList[0]);
            Assert.AreEqual(expectedResult[1], appendedList[1]);
            Assert.AreEqual(expectedResult[2], appendedList[2]);
            Assert.AreEqual(expectedResult[3], appendedList[3]);
            Assert.AreEqual(expectedResult[4], appendedList[4]);
            Assert.AreEqual(expectedResult[5], appendedList[5]);
            Assert.AreEqual(expectedResult[6], appendedList[6]);
            Assert.AreEqual(expectedResult[7], appendedList[7]);
        }
Exemple #5
0
        public void ListsAreDifferent_Defaults_of_String_Of_Same_Lists_Returns_False()
        {
            List <string> newList1 = new List <string>();
            List <string> newList2 = new List <string>();

            Assert.IsFalse(ListLibrary.ListsAreDifferent(newList1, newList2));
        }
Exemple #6
0
        public void ParseListToString_With_Empty_List()
        {
            List <string> numericStringList = new List <string>();
            string        stringOfLists     = ListLibrary.ParseListToString(numericStringList);

            Assert.IsEmpty(stringOfLists);
        }
        public void CombineListsUnique_Returns_Unique_Combined_List_If_Both_Lists_Have_Unique_And_Matching_Items()
        {
            Collection <string> originalList = new Collection <string>()
            {
                "Roo", "Foo", "Soo", "Bar"
            };
            Collection <string> newList = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };
            Collection <string> expectedResult = new Collection <string>()
            {
                "Roo", "Foo", "Soo", "Bar", "Moo", "Nar"
            };

            List <string> combinedList = new List <string>(ListLibrary.CombineListsUnique(originalList, newList));

            Assert.IsTrue(combinedList.Count < newList.Count + originalList.Count);
            Assert.AreEqual(expectedResult[0], combinedList[0]);
            Assert.AreEqual(expectedResult[1], combinedList[1]);
            Assert.AreEqual(expectedResult[2], combinedList[2]);
            Assert.AreEqual(expectedResult[3], combinedList[3]);
            Assert.AreEqual(expectedResult[4], combinedList[4]);
            Assert.AreEqual(expectedResult[5], combinedList[5]);
        }
        public void ConvertToUniqueList_Of_String_Of_Null_Returns_Empty_List()
        {
            IList <string> uniqueList = new List <string>();

            ListLibrary.ConvertToUniqueList(null);

            Assert.IsEmpty(uniqueList);
        }
Exemple #9
0
 public bool ListsAreDifferent_of_String_Of_Outer_Null_List_Returns_True(bool considerOrder, bool considerCapitalization)
 {
     return(ListLibrary.ListsAreDifferent(
                _searchListString,
                null,
                considerOrder: considerOrder,
                caseSensitive: considerCapitalization));
 }
Exemple #10
0
 public bool ListsAreDifferent_of_String_Of_Different_Items_Lists_Returns_True(bool considerOrder, bool considerCapitalization)
 {
     return(ListLibrary.ListsAreDifferent(
                _searchListString,
                _searchListStringDifferentItems,
                considerOrder: considerOrder,
                caseSensitive: considerCapitalization));
 }
Exemple #11
0
        public void ParseRangeToListOfDouble_With_Negative_Numbers_Throws_ArgumentException()
        {
            var ex = Assert.Throws <ArgumentException>(() =>
            {
                ListLibrary.ParseRangeToListOfDouble("-4-11");
            });

            Assert.That(ex.Message, Is.EqualTo("Negative values are not supported."));
        }
Exemple #12
0
        public void ParseListToString()
        {
            List <string> numericStringList = new List <string>()
            {
                "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"
            };
            string stringOfLists = ListLibrary.ParseListToString(numericStringList);

            Assert.AreEqual("1, 2, 3, 4, 5, 6, 7, 8, 9, 10", stringOfLists);
        }
        public void SortCorrelatedLists_With_All_Lists_Null_Returns_All_Null()
        {
            IList <string>          listToSort      = null;
            IList <IList <string> > correlatedLists = null;

            ListLibrary.SortCorrelatedLists(ref listToSort, ref correlatedLists);

            Assert.IsNull(listToSort);
            Assert.IsNull(correlatedLists);
        }
Exemple #14
0
        public void Convert_Incompatible_Returns_Empty()
        {
            List <int> originalList = new List <int>()
            {
                1, 2, 3, 4, 5
            };
            List <char> convertedList = new List <char>(ListLibrary.Convert <int, char>(originalList));

            Assert.IsEmpty(convertedList);
        }
        public void RemoveFromList_Where_OriginalList_Is_Null_Returns_Empty()
        {
            Collection <string> listToRemove = new Collection <string>()
            {
                "Bar", "Nar"
            };
            List <string> filteredList = new List <string>(ListLibrary.RemoveFromList(listToRemove, null));

            Assert.IsEmpty(filteredList);
        }
        public void TrimListOfEmptyItems_WIth_All_Empty_Items_Returns_Empty()
        {
            Collection <string> empty = new Collection <string>()
            {
                "", "", " ", " ", ""
            };
            List <string> trimmedList = new List <string>(ListLibrary.TrimListOfEmptyItems(empty));

            Assert.IsEmpty(trimmedList);
        }
        public void SortCorrelatedLists_With_All_Lists_Empty_Returns_All_Empty()
        {
            IList <string>          listToSort      = new List <string>();
            IList <IList <string> > correlatedLists = new List <IList <string> >();

            ListLibrary.SortCorrelatedLists(ref listToSort, ref correlatedLists);

            Assert.IsEmpty(listToSort);
            Assert.IsEmpty(correlatedLists);
        }
        public void CreateUniqueList_of_String_BaseList_Null_Returns_CheckList()
        {
            List <string> checkList = new List <string> {
                "Foo", "Bar"
            };
            IList <string> uniqueList = new List <string>(ListLibrary.MergeUnique(checkList, null));

            Assert.AreEqual(uniqueList.Count, checkList.Count);
            Assert.AreEqual(checkList[0], uniqueList[0]);
            Assert.AreEqual(checkList[1], uniqueList[1]);
        }
Exemple #19
0
        public void Convert_Compatible_Returns_Converted_List()
        {
            List <ClassForConversion> listToConvert = new List <ClassForConversion>()
            {
                new ClassForConversion(),
                new ClassForConversion(),
                new ClassForConversion()
            };
            List <BaseForConversion> convertedList = new List <BaseForConversion>(ListLibrary.Convert <ClassForConversion, BaseForConversion>(listToConvert));

            Assert.IsTrue(listToConvert.Count == convertedList.Count);
        }
Exemple #20
0
        public string ParseStringToList_Parses_String_To_List_By_Demarcator(string value, string demaractor)
        {
            List <string> values = ListLibrary.ParseStringToList(value, demaractor);

            string result = "";

            foreach (string splitValue in values)
            {
                result += splitValue + " ";
            }
            return(result.Trim());
        }
Exemple #21
0
        public string ParseRangeToListOfDouble(string rangeString)
        {
            IEnumerable <double> listFromRange = ListLibrary.ParseRangeToListOfDouble(rangeString);

            string output = "";

            foreach (double item in listFromRange)
            {
                output += item + ", ";
            }
            output = output.Trim();
            return(output);
        }
Exemple #22
0
        public string ParseRangeToListOfInteger(string rangeString)
        {
            IEnumerable <int> listFromRange = ListLibrary.ParseRangeToListOfInteger(rangeString);

            string output = "";

            foreach (int item in listFromRange)
            {
                output += item + ", ";
            }
            output = output.Trim();
            return(output);
        }
        public void CreateUniqueList_of_String_CheckList_Null_Returns_BaseList()
        {
            List <string> baseList = new List <string> {
                "Bar", "Moo", "Nar"
            };

            IList <string> uniqueList = new List <string>(ListLibrary.MergeUnique(null, baseList));

            Assert.AreEqual(uniqueList.Count, baseList.Count);
            Assert.AreEqual(baseList[0], uniqueList[0]);
            Assert.AreEqual(baseList[1], uniqueList[1]);
            Assert.AreEqual(baseList[2], uniqueList[2]);
        }
Exemple #24
0
        public void ConvertListToObservableCollection_Of_Collection_Of_Double_Returns_Expected()
        {
            List <double> listToConvert = new List <double>()
            {
                1, 2.2, 999, -4
            };
            ObservableCollection <double> convertedList = ListLibrary.ConvertListToObservableCollection <double>(listToConvert);

            Assert.IsTrue(convertedList.Count == listToConvert.Count);
            Assert.AreEqual(listToConvert[0], convertedList[0]);
            Assert.AreEqual(listToConvert[1], convertedList[1]);
            Assert.AreEqual(listToConvert[2], convertedList[2]);
            Assert.AreEqual(listToConvert[3], convertedList[3]);
        }
        public void TrimListOfEmptyItems_With_No_Empty_Items_Returns_Original()
        {
            Collection <string> original = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };
            List <string> trimmedList = new List <string>(ListLibrary.TrimListOfEmptyItems(original));

            Assert.IsTrue(original.Count == trimmedList.Count);
            Assert.AreEqual(original[0], trimmedList[0]);
            Assert.AreEqual(original[1], trimmedList[1]);
            Assert.AreEqual(original[2], trimmedList[2]);
            Assert.AreEqual(original[3], trimmedList[3]);
        }
Exemple #26
0
        public void ConvertListToObservableCollection_Of_List_Of_String_Returns_Expected()
        {
            List <string> listToConvert = new List <string>()
            {
                "Foo", "bar", "Moo", "nar"
            };
            ObservableCollection <string> convertedList = ListLibrary.ConvertListToObservableCollection <string>(listToConvert);

            Assert.IsTrue(convertedList.Count == listToConvert.Count);
            Assert.AreEqual(listToConvert[0], convertedList[0]);
            Assert.AreEqual(listToConvert[1], convertedList[1]);
            Assert.AreEqual(listToConvert[2], convertedList[2]);
            Assert.AreEqual(listToConvert[3], convertedList[3]);
        }
        public void RemoveFromList_Where_All_Original_Items_Removed_Returns_Empty()
        {
            Collection <string> listToRemove = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };
            Collection <string> originalList = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };
            List <string> filteredList = new List <string>(ListLibrary.RemoveFromList(listToRemove, originalList));

            Assert.IsEmpty(filteredList);
        }
        public void RemoveFromList_Where_ListToRemove_Is_Null_Returns_OriginalList()
        {
            Collection <string> originalList = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };
            List <string> filteredList = new List <string>(ListLibrary.RemoveFromList(null, originalList));

            Assert.IsTrue(originalList.Count == filteredList.Count);
            Assert.AreEqual(originalList[0], filteredList[0]);
            Assert.AreEqual(originalList[1], filteredList[1]);
            Assert.AreEqual(originalList[2], filteredList[2]);
            Assert.AreEqual(originalList[3], filteredList[3]);
        }
        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 CombineListsUnique_Returns_List_To_Append_If_Original_List_Is_Null()
        {
            Collection <string> newList = new Collection <string>()
            {
                "Foo", "Bar", "Moo", "Nar"
            };

            List <string> expectedResult = new List <string>(ListLibrary.CombineListsUnique(null, newList));

            Assert.IsTrue(newList.Count == expectedResult.Count);
            Assert.AreEqual(newList[0], expectedResult[0]);
            Assert.AreEqual(newList[1], expectedResult[1]);
            Assert.AreEqual(newList[2], expectedResult[2]);
            Assert.AreEqual(newList[3], expectedResult[3]);
        }