コード例 #1
0
        public void Test_UpgradedSelectionSorter_ShouldThrowExceptionWhenCollectionIsNull()
        {
            var sorter          = new UpgradedSelectionSorter <int>();
            var emptyCollection = new SortableCollection <int>(null);

            emptyCollection.Sort(sorter);
        }
コード例 #2
0
        public void Test_UpgradedSelectionSorter_ShouldSortCorrectly()
        {
            var upgradedSelectionSorter = new UpgradedSelectionSorter <int>();

            collection.Sort(upgradedSelectionSorter);

            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, "UpgradedSelectionSorter should sort correctly.");
        }
コード例 #3
0
ファイル: SortersTests.cs プロジェクト: bstaykov/Telerik-DSA
 public void Test_UpgradedSelectionSorter_ShouldThrowExceptionWhenCollectionIsNull()
 {
     var sorter = new UpgradedSelectionSorter<int>();
     var emptyCollection = new SortableCollection<int>(null);
     emptyCollection.Sort(sorter);
 }
コード例 #4
0
ファイル: SortersTests.cs プロジェクト: bstaykov/Telerik-DSA
        public void Test_UpgradedSelectionSorter_ShouldSortCorrectly()
        {
            var upgradedSelectionSorter = new UpgradedSelectionSorter<int>();
            collection.Sort(upgradedSelectionSorter);

            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, "UpgradedSelectionSorter should sort correctly.");
        }