예제 #1
0
        public void CompareToTests()
        {
            _wordCountInfo = new WordCountInfo("test", 3);
            IWordCountInfo _wordCountInfoEqual = new WordCountInfo("test1", 3); ;
            IWordCountInfo _wordCountInfoGreater = new WordCountInfo("test2", 4); ;
            IWordCountInfo _wordCountInfoLesser = new WordCountInfo("test3", 2); ;

            Assert.AreEqual<int>(0, _wordCountInfo.CompareTo(_wordCountInfoEqual));
            Assert.AreEqual<int>(-1, _wordCountInfo.CompareTo(_wordCountInfoLesser));
            Assert.AreEqual<int>(1, _wordCountInfo.CompareTo(_wordCountInfoGreater));
            Assert.AreEqual<int>(-1, _wordCountInfo.CompareTo(null));
            Assert.AreEqual<int>(-1, _wordCountInfo.CompareTo(new Object()));
        }
예제 #2
0
 public void BubbleSortTest()
 {
     ObservableCollection<object> wordCountList = new ObservableCollection<object>();
     WordCountInfo wc1 = new WordCountInfo("test1", 1);
     WordCountInfo wc2 = new WordCountInfo("test2", 2);
     WordCountInfo wc3 = new WordCountInfo("test3", 3);
     wordCountList.Add(wc1);
     wordCountList.Add(wc2);
     wordCountList.Add(wc3);
     ListExtension.BubbleSort(wordCountList);
     Assert.AreSame(wc1, wordCountList[2]);
     Assert.AreSame(wc2, wordCountList[1]);
     Assert.AreSame(wc3, wordCountList[0]);
 }