예제 #1
0
        public void When_NO_metadata_was_written_Then_read_metadata_returns_default_values()
        {
            var fileName = _util.CreateFile("file");

            (long readContentId, DateTime readLastWriteTime) = IndexingMetadataUtility.ReadMetadata(fileName);

            Assert.That(readContentId, Is.EqualTo(long.MinValue));
            Assert.That(readLastWriteTime, Is.EqualTo(DateTime.MinValue));
        }
예제 #2
0
        public void Written_metadata_Can_be_read()
        {
            var fileName = _util.CreateFile("file");

            long     contentId     = new Random().Next(1, 100);
            DateTime lastWriteTime = DateTime.Now.AddDays(-1);

            IndexingMetadataUtility.WriteMetadata(fileName, contentId, lastWriteTime);

            (long readContentId, DateTime readLastWriteTime) = IndexingMetadataUtility.ReadMetadata(fileName);

            Assert.That(readContentId, Is.EqualTo(contentId));
            Assert.That(readLastWriteTime, Is.EqualTo(lastWriteTime));
        }
예제 #3
0
        public void When_file_is_renamed_Then_metadata_is_not_lost()
        {
            var fileName = _util.CreateFile("file");

            long     contentId     = new Random().Next(1, 100);
            DateTime lastWriteTime = DateTime.Now.AddDays(-1);

            IndexingMetadataUtility.WriteMetadata(fileName, contentId, lastWriteTime);

            var movedFileName = _util.GetFileName("file-moved");

            _util.MoveFile(fileName, movedFileName);

            (long readContentId, DateTime readLastWriteTime) = IndexingMetadataUtility.ReadMetadata(movedFileName);

            Assert.That(readContentId, Is.EqualTo(contentId));
            Assert.That(readLastWriteTime, Is.EqualTo(lastWriteTime));
        }