Esempio n. 1
0
            public void Returns_expected_path(string path)
            {
                // ARRANGE
                var sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());

                // ACT
                var actual = sut.ConvertPathToInternal((UPath)path);

                // ASSERT
                Assert.Equal(path, actual);
            }
Esempio n. 2
0
            public void Throws_IOException()
            {
                // ARRANGE
                var sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());

                // ACT
                var ex = Record.Exception(() => sut.CreateDirectory("/dir2"));

                // ASSERT
                Assert.IsType <IOException>(ex);
            }
Esempio n. 3
0
            public void Returns_expected_length(string path, long expected)
            {
                // ARRANGE
                var sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());

                // ACT
                var actual = sut.GetFileLength(path);

                // ASSERT
                Assert.Equal(expected, actual);
            }
Esempio n. 4
0
            public void Returns_expected_attributes(string path, FileAttributes expected)
            {
                // ARRANGE
                var sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());

                // ACT
                var actual = sut.GetAttributes(path);

                // ASSERT
                Assert.Equal(expected, actual);
            }
Esempio n. 5
0
            public void Throws_DirectoryNotFoundException_when_directory_does_not_exist(string path)
            {
                // ARRANGE
                var    sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());
                Action act = () => sut.EnumeratePaths(path, "*", SearchOption.AllDirectories, SearchTarget.Both).ToArray();

                // ACT
                var ex = Record.Exception(act);

                // ASSERT
                Assert.IsType <DirectoryNotFoundException>(ex);
            }
Esempio n. 6
0
            public void Throws_FileNotFoundException_if_file_does_not_exist(string path)
            {
                // ARRANGE
                var    sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());
                Action act = () => sut.GetFileLength(path);

                // ACT
                var ex = Record.Exception(act);

                // ASSERT
                Assert.IsType <FileNotFoundException>(ex);
            }
Esempio n. 7
0
            public void FileNotFoundException_if_file_does_not_exist(string path)
            {
                // ARRANGE
                var    sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());
                Action act = () => sut.OpenFile(path, FileMode.Open, FileAccess.Read, FileShare.None);

                // ACT
                var ex = Record.Exception(act);

                // ASSERT
                Assert.IsType <FileNotFoundException>(ex);
            }
Esempio n. 8
0
            public void Returns_expected_path(string systemPath)
            {
                // ARRANGE
                var sut      = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());
                var expected = (UPath)systemPath;

                // ACT
                var actual = sut.ConvertPathFromInternal(systemPath);

                // ASSERT
                Assert.Equal(expected, actual);
            }
Esempio n. 9
0
            public void Succeeds_for_read_access(string path)
            {
                // ARRANGE
                var sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());

                // ACT
                using var stream = sut.OpenFile(path, FileMode.Open, FileAccess.Read, FileShare.None);

                // ASSERT
                Assert.False(stream.CanWrite);
                Assert.True(stream.CanRead);
            }
Esempio n. 10
0
            public void Throws_NotSupportedException(string path)
            {
                // ARRANGE
                var    sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());
                Action act = () => sut.Watch(path);

                // ACT
                var ex = Record.Exception(act);

                // ASSERT
                Assert.IsType <NotSupportedException>(ex);
            }
Esempio n. 11
0
            public void Returns_expected_values(string id, string path, string searchPattern, SearchOption searchOption, SearchTarget searchTarget, string[] expected)
            {
                // ARRANGE
                _ = id;
                var sut           = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());
                var expectedPaths = expected.Select(x => (UPath)x).ToHashSet();

                // ACT
                var actualPaths = sut.EnumeratePaths(path, searchPattern, searchOption, searchTarget);

                // ASSERT
                Assert.True(expectedPaths.SetEquals(actualPaths));
            }
Esempio n. 12
0
            public void Throws_IOException_if_file_or_directory_does_not_exist(string path)
            {
                // ARRANGE
                var    sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());
                Action act = () => sut.GetAttributes(path);

                // ACT
                var ex = Record.Exception(act);

                // ASSERT
                Assert.IsType <IOException>(ex);
                Assert.Contains("does not exist", ex.Message);
            }
Esempio n. 13
0
            public void Throws_IOException_for_write_access()
            {
                // ARRANGE
                var sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly());

                // ACT / ASSERT
                Assert.Throws <IOException>(() => sut.OpenFile("/file", FileMode.Open, FileAccess.Write, FileShare.None));
                Assert.Throws <IOException>(() => sut.OpenFile("/file", FileMode.Open, FileAccess.ReadWrite, FileShare.None));

                foreach (var fileMode in Enum.GetValues(typeof(FileMode)).Cast <FileMode>())
                {
                    if (fileMode == FileMode.Open)
                    {
                        continue;
                    }

                    Assert.Throws <IOException>(() => sut.OpenFile("/file", fileMode, FileAccess.Read, FileShare.None));
                }
            }