public void ShouldNotifyComparerChange()
        {
            CategoryItem category     = new CategoryItem(new PropertyGrid(), new CategoryAttribute());
            int          numberRaised = 0;

            category.PropertyChanged += (sender, e) => { if (e.PropertyName == "Comparer")
                                                         {
                                                             numberRaised++;
                                                         }
            };

            PropertyItemComparer comparer = new PropertyItemComparer();

            category.Comparer = comparer;
            category.Comparer = comparer;

            Assert.AreEqual(comparer, category.Comparer);
            Assert.AreEqual <int>(1, numberRaised);
        }
Example #2
0
        public void ComparesOrderedItems()
        {
            PropertyItemComparer comparer = new PropertyItemComparer();

            int result = comparer.Compare(new PropertyItemMock(0), new PropertyItemMock(0));

            Assert.AreEqual <int>(0, result);

            result = comparer.Compare(new PropertyItemMock(0), new PropertyItemMock(1));
            Assert.AreEqual <int>(-1, result);

            result = comparer.Compare(new PropertyItemMock(1), new PropertyItemMock(0));
            Assert.AreEqual <int>(1, result);

            result = comparer.Compare(new PropertyItemMock("a"), new PropertyItemMock("a"));
            Assert.AreEqual <int>(0, result);

            result = comparer.Compare(new PropertyItemMock("a"), new PropertyItemMock("b"));
            Assert.AreEqual <int>(-1, result);

            result = comparer.Compare(new PropertyItemMock("b"), new PropertyItemMock("a"));
            Assert.AreEqual <int>(1, result);
        }
Example #3
0
        public void ComparesNullToValue()
        {
            int result = new PropertyItemComparer().Compare(null, new PropertyItemMock(null));

            Assert.AreEqual <int>(-1, result);
        }
Example #4
0
        public void ComparesValueToNull()
        {
            int result = new PropertyItemComparer().Compare(new PropertyItemMock(null), null);

            Assert.AreEqual <int>(1, result);
        }
Example #5
0
        public void ComparesNullToNull()
        {
            int result = new PropertyItemComparer().Compare(null, null);

            Assert.AreEqual <int>(0, result);
        }