コード例 #1
0
ファイル: XYPointTests.cs プロジェクト: Brondahl/MDMUtils
        public void EqualityComparisonsWork()
        {
            var basePoint               = new XYPoint(0, 2);
            var matchingPoint           = new XYPoint(0, 2);
            var nonMatchingPoint        = new XYPoint(2, 0);
            var anotherNonMatchingPoint = new XYPoint(0, 1);


            Assert.IsTrue(basePoint.Equals(matchingPoint));
            Assert.IsTrue(basePoint == matchingPoint);
            Assert.IsFalse(basePoint != matchingPoint);

            Assert.IsFalse(basePoint.Equals(nonMatchingPoint));
            Assert.IsFalse(basePoint == nonMatchingPoint);
            Assert.IsTrue(basePoint != nonMatchingPoint);

            Assert.IsFalse(basePoint.Equals(anotherNonMatchingPoint));
            Assert.IsFalse(basePoint == anotherNonMatchingPoint);
            Assert.IsTrue(basePoint != anotherNonMatchingPoint);


            Assert.IsFalse(ReferenceEquals(basePoint, matchingPoint));
            Assert.AreEqual(basePoint, matchingPoint);
            Assert.AreNotEqual(basePoint, nonMatchingPoint);
        }
コード例 #2
0
 public void Equals()
 {
   XYPoint p1 = new XYPoint(2,3);
   XYPoint p2 = new XYPoint(2,3);
   XYPoint p3 = new XYPoint(2,-3);
   XYLine l1 = new XYLine(2,3,3,4);
   Assert.AreEqual(true, p1.Equals(p1),"Test1");
   Assert.AreEqual(true, p1.Equals(p2),"Test2");
   Assert.AreEqual(false, p1.Equals(p3),"Test3");
   Assert.AreEqual(false, p1.Equals(l1),"Test4");
 }