public void When_GetFileInfo_and_resource_does_not_exist_then_should_not_get_file_info()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "");

            var fileInfo = provider.GetFileInfo("DoesNotExist.Txt");

            fileInfo.ShouldNotBe(null);
            fileInfo.Exists.ShouldBe(false);
        }
        public void GetDirInfo_with_no_matching_base_namespace()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Unknown.Namespace");

            var files = provider.GetDirectoryContents(string.Empty);

            files.ShouldNotBe(null);
            files.Exists.ShouldBe(true);
            files.Count().ShouldBe(0);
        }
Пример #3
0
        public void TryGetDirInfo_without_slash()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "");

            IEnumerable <IFileInfo> files;

            provider.TryGetDirectoryContents(string.Empty, out files).ShouldBe(false);
            provider.TryGetDirectoryContents("file", out files).ShouldBe(false);
            provider.TryGetDirectoryContents("file.txt", out files).ShouldBe(false);
        }
Пример #4
0
        public void When_TryGetFileInfo_and_resource_does_not_exist_then_should_not_get_file_info()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "");

            IFileInfo fileInfo;

            provider.TryGetFileInfo("/DoesNotExist.Txt", out fileInfo).ShouldBe(false);

            fileInfo.ShouldBe(null);
        }
Пример #5
0
        public void TryGetDirInfo_with_no_matching_base_namespace()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Unknown.Namespace");

            IEnumerable <IFileInfo> files;

            provider.TryGetDirectoryContents(string.Empty, out files).ShouldBe(false);
            provider.TryGetDirectoryContents("/", out files).ShouldBe(true);
            files.Count().ShouldBe(0);
        }
        public void GetDirectoryContents()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Resources");

            var files = provider.GetDirectoryContents("");

            files.ShouldNotBe(null);
            files.Count().ShouldBe(2);
            provider.GetDirectoryContents("file").Exists.ShouldBe(false);
            provider.GetDirectoryContents("file/").Exists.ShouldBe(false);
            provider.GetDirectoryContents("file.txt").Exists.ShouldBe(false);
            provider.GetDirectoryContents("file/txt").Exists.ShouldBe(false);
        }
        public void When_GetFileInfo_and_resources_in_path_then_should_get_file_infos()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "");

            var fileInfo = provider.GetFileInfo("Resources/File.txt");

            fileInfo.ShouldNotBe(null);
            fileInfo.Exists.ShouldBe(true);
            fileInfo.LastModified.ShouldNotBe(default(DateTime));
            fileInfo.Length.ShouldBeGreaterThan(0);
            fileInfo.IsDirectory.ShouldBe(false);
            fileInfo.PhysicalPath.ShouldBe(null);
            fileInfo.Name.ShouldBe("File.txt");
        }
Пример #8
0
        public void TryGetDirInfo_with_slash()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Resources");

            IEnumerable <IFileInfo> files;

            provider.TryGetDirectoryContents("/", out files).ShouldBe(true);
            files.Count().ShouldBe(2);

            provider.TryGetDirectoryContents("/file", out files).ShouldBe(false);
            provider.TryGetDirectoryContents("/file/", out files).ShouldBe(false);
            provider.TryGetDirectoryContents("/file.txt", out files).ShouldBe(false);
            provider.TryGetDirectoryContents("/file/txt", out files).ShouldBe(false);
        }
Пример #9
0
        public void When_TryGetFileInfo_and_resource_exists_in_subdirectory_then_should_get_file_info()
        {
            var provider = new EmbeddedResourceFileSystem(this.GetType().Assembly, "Resources");

            IFileInfo fileInfo;

            provider.TryGetFileInfo("/ResourcesInSubdirectory/File3.txt", out fileInfo).ShouldBe(true);

            fileInfo.ShouldNotBe(null);
            fileInfo.LastModified.ShouldNotBe(default(DateTime));
            fileInfo.Length.ShouldBeGreaterThan(0);
            fileInfo.IsDirectory.ShouldBe(false);
            fileInfo.PhysicalPath.ShouldBe(null);
            fileInfo.Name.ShouldBe("ResourcesInSubdirectory/File3.txt");
        }
        public void When_GetFileInfo_and_resource_exists_in_root_then_should_get_file_info()
        {
            var provider           = new EmbeddedResourceFileSystem(this.GetType().Assembly, "");
            var expectedFileLength = new FileInfo("File.txt").Length;
            var fileInfo           = provider.GetFileInfo("File.txt");

            fileInfo.ShouldNotBe(null);
            fileInfo.Exists.ShouldBe(true);
            fileInfo.LastModified.ShouldNotBe(default(DateTime));
            fileInfo.Length.ShouldBe(expectedFileLength);
            fileInfo.IsDirectory.ShouldBe(false);
            fileInfo.PhysicalPath.ShouldBe(null);
            fileInfo.Name.ShouldBe("File.txt");

            //Passing in a leading slash
            fileInfo = provider.GetFileInfo("/File.txt");
            fileInfo.ShouldNotBe(null);
            fileInfo.Exists.ShouldBe(true);
            fileInfo.LastModified.ShouldNotBe(default(DateTime));
            fileInfo.Length.ShouldBe(expectedFileLength);
            fileInfo.IsDirectory.ShouldBe(false);
            fileInfo.PhysicalPath.ShouldBe(null);
            fileInfo.Name.ShouldBe("File.txt");
        }