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); }
public void Throws_IOException() { // ARRANGE var sut = new EmbeddedResourcesFileSystem(Assembly.GetExecutingAssembly()); // ACT var ex = Record.Exception(() => sut.CreateDirectory("/dir2")); // ASSERT Assert.IsType <IOException>(ex); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
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); }
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)); } }