コード例 #1
0
        public void testEnsureLogTimeAndTimeZoneOffsetAreCurrentValues()
        {
            long commitTime = 1154236443000L;
            int  tz         = -4 * 60;

            Core.Tree t = new Core.Tree(db);
            addFileToTree(t, "i-am-a-file", "and this is the data in me\n");
            commit(t, "A Commit\n", new PersonIdent(author, commitTime, tz), new PersonIdent(committer, commitTime, tz));
            IList <ReflogReader.Entry> entries = db.ReflogReader(Constants.HEAD).getReverseEntries();

            Assert.AreEqual(1, entries.Count);

            var entry = entries[0];

            SystemReader mockSystemReader = SystemReader.getInstance();
            long         fakeCurrentTime  = mockSystemReader.getCurrentTime();
            long         remainder        = fakeCurrentTime % 1000;

            fakeCurrentTime -= remainder; // Second based Unix time format is used to store timetamps in the log. Thus, milliseconds are truncated.

            Assert.AreEqual(fakeCurrentTime, entry.getWho().When);
            Assert.AreEqual(mockSystemReader.getTimezone(fakeCurrentTime), entry.getWho().TimeZoneOffset);
        }