コード例 #1
0
        public void testBuildOneFile_FinishWriteCommit()
        {
            string path = "a-File-path";
            var mode = GitSharp.FileMode.RegularFile;
            long lastModified = 1218123387057L;
            int Length = 1342;
            DirCacheEntry entOrig;

            DirCache dc = DirCache.Lock(db);
            DirCacheBuilder b = dc.builder();
            Assert.IsNotNull(b);

            entOrig = new DirCacheEntry(path);
            entOrig.setFileMode(mode);
            entOrig.setLastModified(lastModified);
            entOrig.setLength(Length);

            Assert.AreNotSame(path, entOrig.getPathString());
            Assert.AreEqual(path, entOrig.getPathString());
            Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId());
            Assert.AreEqual(mode.Bits, entOrig.getRawMode());
            Assert.AreEqual(0, entOrig.getStage());
            Assert.AreEqual(lastModified, entOrig.getLastModified());
            Assert.AreEqual(Length, entOrig.getLength());
            Assert.IsFalse(entOrig.isAssumeValid());
            b.add(entOrig);

            b.finish();
            Assert.AreEqual(1, dc.getEntryCount());
            Assert.AreSame(entOrig, dc.getEntry(0));

            dc.write();
            Assert.IsTrue(dc.commit());

            dc = DirCache.read(db);
            Assert.AreEqual(1, dc.getEntryCount());

            DirCacheEntry entRead = dc.getEntry(0);
            Assert.AreNotSame(entOrig, entRead);
            Assert.AreEqual(path, entRead.getPathString());
            Assert.AreEqual(ObjectId.ZeroId, entOrig.getObjectId());
            Assert.AreEqual(mode.Bits, entOrig.getRawMode());
            Assert.AreEqual(0, entOrig.getStage());
            Assert.AreEqual(lastModified, entOrig.getLastModified());
            Assert.AreEqual(Length, entOrig.getLength());
            Assert.IsFalse(entOrig.isAssumeValid());
        }