示例#1
0
        public void Test_MergeInsertionSorter_ShouldThrowExceptionWhenCollectionIsNull()
        {
            var sorter          = new MergeInsertionSorter <int>();
            var emptyCollection = new SortableCollection <int>(null);

            emptyCollection.Sort(sorter);
        }
示例#2
0
        public void Test_MergeInsertionSorter_ShouldSortCorrectly()
        {
            var mergeInsertionSorter = new MergeInsertionSorter<int>();
            collection.Sort(mergeInsertionSorter);

            bool isSortedCorrectly = true;
            for (int i = 0; i < collection.Items.Count - 1; i++)
            {
                if (collection.Items[i].CompareTo(collection.Items[i + 1]) > 0)
                {
                    isSortedCorrectly = false;
                    break;
                }
            }

            Assert.IsTrue(isSortedCorrectly, "MergeInsertionSorter should sort correctly.");
        }
示例#3
0
        public void Test_MergeInsertionSorter_ShouldSortCorrectly()
        {
            var mergeInsertionSorter = new MergeInsertionSorter <int>();

            collection.Sort(mergeInsertionSorter);

            bool isSortedCorrectly = true;

            for (int i = 0; i < collection.Items.Count - 1; i++)
            {
                if (collection.Items[i].CompareTo(collection.Items[i + 1]) > 0)
                {
                    isSortedCorrectly = false;
                    break;
                }
            }

            Assert.IsTrue(isSortedCorrectly, "MergeInsertionSorter should sort correctly.");
        }
示例#4
0
 public void Test_MergeInsertionSorter_ShouldThrowExceptionWhenCollectionIsNull()
 {
     var sorter = new MergeInsertionSorter<int>();
     var emptyCollection = new SortableCollection<int>(null);
     emptyCollection.Sort(sorter);
 }