Ejemplo n.º 1
0
        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);
            });
        }
Ejemplo n.º 2
0
        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));
            });
        }
Ejemplo n.º 3
0
        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));
            });
        }
Ejemplo n.º 4
0
        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);
            });
        }
Ejemplo n.º 5
0
        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());
            });
        }
Ejemplo n.º 6
0
        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);
            });
        }
Ejemplo n.º 7
0
        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);
            });
        }
Ejemplo n.º 8
0
        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));
            });
        }
Ejemplo n.º 9
0
        /// <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));
        }
Ejemplo n.º 10
0
        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));
            });
        }
Ejemplo n.º 11
0
        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);
            });
        }