Ejemplo n.º 1
0
        public void NodeDates_CreationDates()
        {
            Folder folder = null;

            try
            {
                var t00 = GetTimes(null);

                Thread.Sleep(100);

                folder = new Folder(TestRoot);
                var t01 = GetTimes(folder);

                Thread.Sleep(100);

                folder.Save();
                var t02      = GetTimes(folder);
                var folderId = folder.Id;

                Thread.Sleep(100);

                folder = Node.Load <Folder>(folderId);
                var t03 = GetTimes(folder);

                Thread.Sleep(100);

                folder.CheckOut();
                var t04 = GetTimes(folder);

                Thread.Sleep(100);

                folder.Index++;
                folder.Save();
                var t05 = GetTimes(folder);

                Thread.Sleep(100);

                folder.CheckIn();
                var t06 = GetTimes(folder);

                Thread.Sleep(100);


                folder = Node.Load <Folder>(folderId);
                folder.CheckOut();
                folder.Index++;
                folder.Save();
                var t07 = GetTimes(folder);

                Thread.Sleep(100);

                folder.UndoCheckOut();
                var t08 = GetTimes(folder);

                // CreationDate is earlier than after-construction time but older than test-start time.
                Assert.IsTrue(t00.CurrentTime.CompareTo(t01.CreationDate) < 0);
                Assert.IsTrue(t01.CurrentTime.CompareTo(t01.CreationDate) >= 0);

                // CreationDate is constant.
                Assert.AreEqual(t01.CreationDate, t02.CreationDate);
                Assert.AreEqual(t01.CreationDate, t03.CreationDate);
                Assert.AreEqual(t01.CreationDate, t04.CreationDate);
                Assert.AreEqual(t01.CreationDate, t05.CreationDate);
                Assert.AreEqual(t01.CreationDate, t06.CreationDate);
                Assert.AreEqual(t01.CreationDate, t07.CreationDate);
                Assert.AreEqual(t01.CreationDate, t08.CreationDate); // sql rounding problem

                // CreationDate and CreationDate are equal if there is only one version but different in case of more versions exist.
                Assert.AreEqual(t01.CreationDate, t01.VersionCreationDate);
                Assert.AreEqual(t01.VersionCreationDate, t02.VersionCreationDate);
                Assert.AreEqual(t02.VersionCreationDate, t03.VersionCreationDate);
                Assert.AreNotEqual(t03.VersionCreationDate, t04.VersionCreationDate);
                Assert.AreEqual(t04.VersionCreationDate, t05.VersionCreationDate);
                Assert.AreNotEqual(t05.VersionCreationDate, t06.VersionCreationDate);
                Assert.AreNotEqual(t06.VersionCreationDate, t07.VersionCreationDate);
                Assert.AreNotEqual(t07.VersionCreationDate, t08.VersionCreationDate);

                Assert.IsTrue(t01.CreationDate == t01.VersionCreationDate);
                Assert.IsTrue(t01.VersionCreationDate == t02.VersionCreationDate);
                Assert.IsTrue(t02.VersionCreationDate == t03.VersionCreationDate);
                Assert.IsTrue(t03.VersionCreationDate.CompareTo(t04.VersionCreationDate) < 0);
                Assert.IsTrue(t04.VersionCreationDate == t05.VersionCreationDate);
                Assert.IsTrue(t05.VersionCreationDate.CompareTo(t06.VersionCreationDate) < 0);
                Assert.IsTrue(t06.VersionCreationDate.CompareTo(t07.VersionCreationDate) < 0);
                Assert.IsTrue(t06.VersionCreationDate.CompareTo(t08.VersionCreationDate) <= 0 && t08.VersionCreationDate.CompareTo(t07.VersionCreationDate) <= 0);
            }
            finally
            {
                folder.ForceDelete();
            }
        }