public async Task OperatorNotEqualsTest2() { await STATask.Run(() => { var shellFile1 = ShellFactory.FromFilePath(Path.Combine(TestConfig.TestDirectory.FullName, @"Test.txt")); var shellFile2 = ShellFactory.FromFilePath(Path.Combine(TestConfig.TestDirectory.FullName, @"Test.txt")); Assert.False(shellFile1 != shellFile2); }); }
public async Task NotEqualsTest2() { await STATask.Run(() => { var shellFile1 = ShellFactory.FromFilePath(Path.Combine(TestConfig.TestDirectory.FullName, @"Test.txt")); Object shellFile2 = "abcdefg"; Assert.False(shellFile1.Equals(shellFile2)); }); }
public async Task EqualsObjectTest() { await STATask.Run(() => { var shellFile1 = ShellFactory.FromFilePath(Path.Combine(TestConfig.TestDirectory.FullName, @"Test.txt")); Object shellFile2 = ShellFactory.FromFilePath(Path.Combine(TestConfig.TestDirectory.FullName, @"Test.txt")); Assert.True(shellFile1.Equals(shellFile2)); }); }
public async Task FromFilePathErrorTest() { await STATask.Run(() => { const string filename = @"xxxx.txt"; var path = Path.Combine(TestConfig.TestDirectory.FullName, filename); var ex = Assert.Throws <FileNotFoundException>(() => ShellFactory.FromFilePath(path)); Assert.Equal(path, ex.FileName); }); }
public async Task GetHashCodeTest() { await STATask.Run(() => { const string fileName = @"Test.txt"; var path = Path.Combine(TestConfig.TestDirectory.FullName, fileName); var actual = ShellFactory.FromFilePath(path); Assert.NotEqual(0, actual.GetHashCode()); }); }
public async Task SizePropertyTest() { await STATask.Run(() => { const string fileName = @"Test.txt"; var path = Path.Combine(TestConfig.TestDirectory.FullName, fileName); var actual = ShellFactory.FromFilePath(path); Console.WriteLine(actual.Size); Assert.True(0 < actual.Size); }); }
public async Task FolderPropertyTest() { await STATask.Run(() => { const string fileName = @"Test.txt"; var path = Path.Combine(TestConfig.TestDirectory.FullName, fileName); var actual = ShellFactory.FromFilePath(path); Assert.NotNull(actual.Folder); Assert.Equal(TestConfig.TestDirectory.FullName, actual.Folder.ParsingName); }); }
public async Task ToStringTest() { await STATask.Run(() => { const string fileName = @"Test.txt"; var path = Path.Combine(TestConfig.TestDirectory.FullName, fileName); var actual = ShellFactory.FromFilePath(path); Console.WriteLine(actual.ToString()); Assert.NotEqual(-1, actual.ToString().IndexOf(path, StringComparison.InvariantCultureIgnoreCase)); }); }
/// <summary> /// Create a new instance of the <see cref="ShellLibrary" /> class /// to the specified library name and folder path. /// </summary> /// <param name="libraryName">Name of the library to be created.</param> /// <param name="sourcePath">Folder path.</param> /// <param name="isReadOnly">A value that indicates whether the library is readonly.</param> /// <returns>Created <see cref="ShellLibrary" />.</returns> public static ShellLibrary Load(string libraryName, string sourcePath, bool isReadOnly = true) { Contract.Requires <ArgumentException>(!String.IsNullOrWhiteSpace(libraryName)); Contract.Requires <ArgumentException>(!String.IsNullOrWhiteSpace(sourcePath)); Contract.Ensures(Contract.Result <ShellLibrary>() != null); var shellItemPath = Path.Combine(sourcePath, libraryName + FileExtension); var shellLibraryInterface = CreateShellLibraryNativeInterface(); var item = ShellFactory.FromFilePath(shellItemPath); var shellItem = item.ShellItem.ShellItemInterface; var flags = isReadOnly ? STGM.STGM_READ : STGM.STGM_READWRITE; shellLibraryInterface.LoadLibraryFromItem(shellItem, flags); return(new ShellLibrary(new ShellItem(shellItem), shellLibraryInterface, libraryName)); }
public async Task GetDisplayNameTest() { await STATask.Run(() => { const string fileName = @"Test.txt"; var path = Path.Combine(TestConfig.TestDirectory.FullName, fileName); var actual = ShellFactory.FromFilePath(path); Assert.NotNull(actual); Assert.Equal(fileName, actual.GetDisplayName(DisplayNameTypes.Default)); Assert.Equal(fileName, actual.GetDisplayName(DisplayNameTypes.RelativeToParent)); Assert.Equal(fileName, actual.GetDisplayName(DisplayNameTypes.RelativeToParentAddressBar)); Assert.Equal(path, actual.GetDisplayName(DisplayNameTypes.RelativeToDesktop)); Assert.Equal(fileName, actual.GetDisplayName(DisplayNameTypes.RelativeToParentEditing)); Assert.Equal(path, actual.GetDisplayName(DisplayNameTypes.RelativeToDesktopEditing)); Assert.Equal(path, actual.GetDisplayName(DisplayNameTypes.FileSystemPath)); }); }
public async Task FromFilePathTest() { await STATask.Run(() => { const string filename = @"Test.txt"; var path = Path.Combine(TestConfig.TestDirectory.FullName, filename); var actual = ShellFactory.FromFilePath(path); // Path Assert.NotNull(actual); Assert.Equal(path, actual.Path); Assert.Equal(path, actual.ParsingName); Assert.Equal(filename, actual.Name); Assert.Equal(".txt", actual.Extension); Assert.Equal(TestConfig.TestDirectory.FullName, actual.Folder.ParsingName); // Flags Assert.True(actual.IsFileSystem); }); }