Esempio n. 1
0
        public void testEqualsIsIdentity()
        {
            RevCommit a1 = Commit();
            RevCommit b1 = Commit();

            Assert.IsTrue(a1.Equals(a1));
            Assert.IsTrue(a1.Equals((object)a1));
            Assert.IsFalse(a1.Equals(b1));

            Assert.IsFalse(a1.Equals(a1.Copy()));
            Assert.IsFalse(a1.Equals((object)a1.Copy()));
            Assert.IsFalse(a1.Equals(string.Empty));

            var       rw2 = new GitSharp.Core.RevWalk.RevWalk(db);
            RevCommit a2  = rw2.parseCommit(a1);
            RevCommit b2  = rw2.parseCommit(b1);

            Assert.AreNotSame(a1, a2);
            Assert.AreNotSame(b1, b2);

            Assert.IsFalse(a1.Equals(a2));
            Assert.IsFalse(b1.Equals(b2));

            Assert.AreEqual(a1.GetHashCode(), a2.GetHashCode());
            Assert.AreEqual(b1.GetHashCode(), b2.GetHashCode());

            Assert.IsTrue(AnyObjectId.equals(a1, a2));
            Assert.IsTrue(AnyObjectId.equals(b1, b2));
        }
Esempio n. 2
0
        public void testNoCacheObjectIdSubclass()
        {
            string    newRef = "refs/heads/abc";
            RefUpdate ru     = updateRef(newRef);
            RevCommit newid  = new RevCommit(ru.getNewObjectId())
            {
                // empty
            };

            ru.setNewObjectId(newid);
            RefUpdate.RefUpdateResult update = ru.update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.NEW, update);
            Core.Ref r = db.getAllRefs()[newRef];
            Assert.IsNotNull(r);
            Assert.AreEqual(newRef, r.Name);
            Assert.IsNotNull(r.ObjectId);
            Assert.AreNotSame(newid, r.ObjectId);
            Assert.AreSame(typeof(ObjectId), r.ObjectId.GetType());
            Assert.AreEqual(newid.Copy(), r.ObjectId);
            IList <ReflogReader.Entry> reverseEntries1 = db.ReflogReader("refs/heads/abc").getReverseEntries();

            ReflogReader.Entry entry1 = reverseEntries1[0];
            Assert.AreEqual(1, reverseEntries1.Count);
            Assert.AreEqual(ObjectId.ZeroId, entry1.getOldId());
            Assert.AreEqual(r.ObjectId, entry1.getNewId());
            Assert.AreEqual(new PersonIdent(db).ToString(), entry1.getWho().ToString());
            Assert.AreEqual("", entry1.getComment());
            IList <ReflogReader.Entry> reverseEntries2 = db.ReflogReader("HEAD").getReverseEntries();

            Assert.AreEqual(0, reverseEntries2.Count);
        }