Exemplo n.º 1
0
        public void Equals2()
        {
            var edge1 = new SReversedEdge <int, EquatableEdge <int> >(new EquatableEdge <int>(1, 2));
            var edge2 = new SReversedEdge <int, EquatableEdge <int> >(new EquatableEdge <int>(1, 2));
            var edge3 = new SReversedEdge <int, EquatableEdge <int> >(new EquatableEdge <int>(2, 1));

            Assert.AreEqual(edge1, edge1);
            Assert.AreEqual(edge1, edge2);
            Assert.IsTrue(edge1.Equals((object)edge2));
            Assert.AreNotEqual(edge1, edge3);

            Assert.IsFalse(edge1.Equals(null));
            Assert.AreNotEqual(edge1, null);
        }
Exemplo n.º 2
0
        public void Equals()
        {
            var wrappedEdge = new Edge <int>(1, 2);
            var edge1       = new SReversedEdge <int, Edge <int> >(wrappedEdge);
            var edge2       = new SReversedEdge <int, Edge <int> >(wrappedEdge);
            var edge3       = new SReversedEdge <int, Edge <int> >(new Edge <int>(1, 2));
            var edge4       = new SReversedEdge <int, Edge <int> >(new Edge <int>(2, 1));

            Assert.AreEqual(edge1, edge1);

            Assert.AreEqual(edge1, edge2);
            Assert.AreEqual(edge2, edge1);
            Assert.IsTrue(edge1.Equals((object)edge2));
            Assert.IsTrue(edge1.Equals(edge2));
            Assert.IsTrue(edge2.Equals(edge1));

            Assert.AreNotEqual(edge1, edge3);
            Assert.AreNotEqual(edge3, edge1);
            Assert.IsFalse(edge1.Equals((object)edge3));
            Assert.IsFalse(edge1.Equals(edge3));
            Assert.IsFalse(edge3.Equals(edge1));

            Assert.AreNotEqual(edge1, edge4);
            Assert.AreNotEqual(edge4, edge1);
            Assert.IsFalse(edge1.Equals((object)edge4));
            Assert.IsFalse(edge1.Equals(edge4));
            Assert.IsFalse(edge4.Equals(edge1));

            Assert.AreNotEqual(edge1, null);
            Assert.IsFalse(edge1.Equals(null));
        }
Exemplo n.º 3
0
        public void EqualsDefaultEdge_ReferenceTypeExtremities()
        {
            var edge1 = default(SReversedEdge <int, Edge <int> >);
            var edge2 = new SReversedEdge <int, Edge <int> >();

            Assert.AreEqual(edge1, edge2);
            Assert.AreEqual(edge2, edge1);
            Assert.IsTrue(edge1.Equals(edge2));
            Assert.IsTrue(edge2.Equals(edge1));
        }
Exemplo n.º 4
0
        public void SReversedEdgeTestEverything()
        {
            var originalEdge1 = new SEquatableEdge <int>(0, 1);
            var reversedEdge1 = new SReversedEdge <int, SEquatableEdge <int> >(originalEdge1);

            Assert.AreEqual(1, reversedEdge1.Source);
            Assert.AreEqual(0, reversedEdge1.Target);
            Assert.AreEqual(String.Format("R({0}->{1})", 0, 1), reversedEdge1.ToString());

            //equatable parts
            var originalEdge2 = new SEquatableEdge <int>(2, 3);
            var reversedEdge2 = new SReversedEdge <int, SEquatableEdge <int> >(originalEdge2);

            Assert.IsFalse(reversedEdge1.Equals(reversedEdge2));
            Assert.IsFalse(reversedEdge1.Equals(1));
            Assert.IsFalse(reversedEdge1 == reversedEdge2);
            Assert.IsTrue(reversedEdge1 != reversedEdge2);
            Assert.IsFalse(reversedEdge1.GetHashCode() == reversedEdge2.GetHashCode());
        }