示例#1
0
        public void EqualTest()
        {
            pcTest pt1 = new pcTest {
                Name = "1"
            };
            PropertyCompare <pcTest> pcCompare = new PropertyCompare <pcTest>("Name");

            Assert.AreEqual(pcCompare.Compare(pt1, pt1), 0);
        }
示例#2
0
        public void CompareTest()
        {
            pcTest pt1 = new pcTest {
                Name = "1"
            };
            pcTest pt2 = new pcTest {
                Name = "2"
            };
            PropertyCompare <pcTest> pcCompare = new PropertyCompare <pcTest>("Name");

            Assert.IsTrue(pcCompare.Compare(pt1, pt2) < 0);
        }
示例#3
0
        public void NullExceptionTest()
        {
            pcTest pt1 = new pcTest {
                PC = new pc {
                    Name = "1"
                }
            };
            pcTest pt2 = new pcTest {
                PC = new pc {
                    Name = "2"
                }
            };
            PropertyCompare <pcTest> pcCompare = new PropertyCompare <pcTest>();

            Assert.IsTrue(pcCompare.Compare(pt1, pt2) < 0);
        }
示例#4
0
        public void CompareListTest()
        {
            pcTest pt1 = new pcTest {
                Name = "1", PP = new pp {
                    Name = "2"
                }
            };
            pcTest pt2 = new pcTest {
                Name = "1", PP = new pp {
                    Name = "1"
                }
            };
            PropertyCompareList <pcTest> pcCompare = new PropertyCompareList <pcTest>();

            pcCompare.Add("Name");
            pcCompare.Add("PP");
            Assert.IsTrue(pcCompare.Compare(pt1, pt2) > 0);

            pcCompare = new PropertyCompareList <pcTest>(new PropertyCompare <pcTest>(t => t.Name), new PropertyCompare <pcTest>(t => t.PP));
            Assert.IsTrue(pcCompare.Compare(pt1, pt2) > 0);
        }