Пример #1
0
        public void Convert_detection_of_file_properties_files_is_case_invariant()
        {
            var file1 = new EmptyFile(s_File1);
            var filePropertiesFile = FilePropertiesFile.ForFile(null, file1);

            var mock = new Mock<IReadableFile>(MockBehavior.Strict);
            mock.Setup(f => f.Name).Returns(file1.Name + FilePropertiesFile.FileNameSuffix.ToUpper());
            mock.Setup(f => f.OpenRead()).Returns(filePropertiesFile.OpenRead());

            var directoryCreator = new LocalItemCreator();
            using (var temporaryDirectory = directoryCreator.CreateTemporaryDirectory(
                new Directory(Path.GetRandomFileName())
                {
                    dir =>
                    {
                        mock.Setup(d => d.Parent).Returns(dir);
                        return mock.Object;
                    }
                }))
            {
                var metaFs = m_Instance.Convert(temporaryDirectory.Directory);

                Assert.Empty(metaFs.Directories);
                Assert.True(metaFs.GetFile(s_File1 + FilePropertiesFile.FileNameSuffix) is FilePropertiesFile);
            }

        }
Пример #2
0
        public void Open_returns_json_readable_stream()
        {
            var file = new EmptyFile("file1") { LastWriteTime = DateTime.Now, Length = 42};
            var filePropertiesFile = FilePropertiesFile.ForFile(null, file);

            FileProperties properties;
            using (var jsonReader = new JsonTextReader(new StreamReader(filePropertiesFile.OpenRead())))
            {
                properties = m_Serializer.Deserialize<FileProperties>(jsonReader);
            }

            Assert.NotNull(properties);
            Assert.Equal(file.Name, properties.Name);
            Assert.Equal(file.Length, properties.Length);
            Assert.Equal(file.LastWriteTime, properties.LastWriteTime);
        }