Esempio n. 1
0
        /// <summary>
        /// Used in sorting of list
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(-1);
            }

            IWordCountInfo tocompare = (obj as IWordCountInfo);

            if (tocompare == null)
            {
                return(-1);
            }

            if (tocompare.Count == this.Count)
            {
                return(0);
            }
            else if (tocompare.Count > this.Count)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
 public void OnPropertyChangedTests()
 {
     _wordCountInfo = new WordCountInfo("test", 3);
     string propertyName = string.Empty;
     _wordCountInfo.PropertyChanged +=delegate (object sender, PropertyChangedEventArgs e)
     {
         propertyName = e.PropertyName;
     };
     _wordCountInfo.Count = 4;
     Assert.AreEqual<string>("DisplayInfo", propertyName);
 }
        public void OnPropertyChangedTests()
        {
            _wordCountInfo = new WordCountInfo("test", 3);
            string propertyName = string.Empty;

            _wordCountInfo.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                propertyName = e.PropertyName;
            };
            _wordCountInfo.Count = 4;
            Assert.AreEqual <string>("DisplayInfo", propertyName);
        }
        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()));
        }
        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()));
        }
 public void CountNegativeExceptionTest()
 {
     _wordCountInfo = new WordCountInfo("test",0);
     _wordCountInfo.Count = -1;
 }
 public void ConstructorCountNegativeExceptionTest()
 {
     _wordCountInfo = new WordCountInfo("test", -3);
 }
 public void ConstructorWordNullExceptionTest()
 {
     _wordCountInfo = new WordCountInfo("", 3);
 }
 public void DisplayInfoTests()
 {
     _wordCountInfo = new WordCountInfo("test",3);
     Assert.AreEqual<string>("test - 3", _wordCountInfo.DisplayInfo);
 }
Esempio n. 10
0
 public void CountNegativeExceptionTest()
 {
     _wordCountInfo       = new WordCountInfo("test", 0);
     _wordCountInfo.Count = -1;
 }
Esempio n. 11
0
 public void ConstructorCountNegativeExceptionTest()
 {
     _wordCountInfo = new WordCountInfo("test", -3);
 }
Esempio n. 12
0
 public void ConstructorWordNullExceptionTest()
 {
     _wordCountInfo = new WordCountInfo("", 3);
 }
Esempio n. 13
0
 public void DisplayInfoTests()
 {
     _wordCountInfo = new WordCountInfo("test", 3);
     Assert.AreEqual <string>("test - 3", _wordCountInfo.DisplayInfo);
 }