Exemple #1
0
        public void LoadContextMenusMustNotLoadRunAsAdminAndOpenContainingFolderForFolder(string path)
        {
            // Arrange
            var mockapi           = new Mock <IPublicAPI>();
            var pluginInitContext = new PluginInitContext()
            {
                API = mockapi.Object
            };

            ContextMenuLoader contextMenuLoader = new ContextMenuLoader(pluginInitContext);

            // Act
            Result result = new Result
            {
                ContextData = new SearchResult {
                    Path = path
                },
            };

            List <ContextMenuResult> contextMenuItems = contextMenuLoader.LoadContextMenus(result);

            // Assert
            Assert.AreEqual(2, contextMenuItems.Count);
            Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_copy_path, contextMenuItems[0].Title);
            Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_open_in_console, contextMenuItems[1].Title);
        }
Exemple #2
0
        public void LoadContextMenusMustLoadAllItemsWhenFileIsAnApp(string path)
        {
            // Arrange
            var mockapi           = new Mock <IPublicAPI>();
            var pluginInitContext = new PluginInitContext()
            {
                API = mockapi.Object
            };

            ContextMenuLoader contextMenuLoader = new ContextMenuLoader(pluginInitContext);

            // Act
            Result result = new Result
            {
                ContextData = new SearchResult {
                    Path = path
                },
            };

            List <ContextMenuResult> contextMenuItems = contextMenuLoader.LoadContextMenus(result);

            // Assert
            Assert.AreEqual(4, contextMenuItems.Count);
            Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_open_containing_folder, contextMenuItems[0].Title);
            Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_run_as_administrator, contextMenuItems[1].Title);
            Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_copy_path, contextMenuItems[2].Title);
            Assert.AreEqual(Microsoft.Plugin.Indexer.Properties.Resources.Microsoft_plugin_indexer_open_in_console, contextMenuItems[3].Title);
        }
Exemple #3
0
        public void ContextMenuLoader_ReturnContextMenuForFileWithOpenInConsole_WhenLoadContextMenusIsCalled()
        {
            // Arrange
            var mock = new Mock <IPublicAPI>();
            var pluginInitContext = new PluginInitContext()
            {
                API = mock.Object
            };
            var contextMenuLoader = new ContextMenuLoader(pluginInitContext);
            var searchResult      = new SearchResult()
            {
                Type = ResultType.File, FullPath = "C:/DummyFile.cs"
            };
            var result = new Result()
            {
                ContextData = searchResult
            };

            // Act
            List <ContextMenuResult> contextMenuResults = contextMenuLoader.LoadContextMenus(result);

            // Assert
            Assert.AreEqual(contextMenuResults.Count, 3);
            Assert.AreEqual(contextMenuResults[0].Title, Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_open_containing_folder);
            Assert.AreEqual(contextMenuResults[1].Title, Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_copy_path);
            Assert.AreEqual(contextMenuResults[2].Title, Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_open_in_console);
        }
Exemple #4
0
        public void LoadContextMenus_MustNotLoadRunAsAdminAndOpenContainingFolder_ForFolder(string path)
        {
            // Arrange
            var mockapi           = new Mock <IPublicAPI>();
            var pluginInitContext = new PluginInitContext()
            {
                API = mockapi.Object
            };

            ContextMenuLoader contextMenuLoader = new ContextMenuLoader(pluginInitContext);

            // Act
            Result result = new Result
            {
                ContextData = new SearchResult {
                    Path = path
                },
            };

            List <ContextMenuResult> contextMenuItems = contextMenuLoader.LoadContextMenus(result);

            // Assert
            Assert.AreEqual(contextMenuItems.Count, 2);
            mockapi.Verify(m => m.GetTranslation("Microsoft_plugin_indexer_copy_path"), Times.Once());
            mockapi.Verify(m => m.GetTranslation("Microsoft_plugin_indexer_run_as_administrator"), Times.Never());
            mockapi.Verify(m => m.GetTranslation("Microsoft_plugin_indexer_open_containing_folder"), Times.Never());
            mockapi.Verify(m => m.GetTranslation("Microsoft_plugin_indexer_open_in_console"), Times.Once());
        }
        public void ContextMenuLoader_ReturnContextMenuForFileWithOpenInConsole_WhenLoadContextMenusIsCalled()
        {
            // Arrange
            var mock = new Mock <IPublicAPI>();

            mock.Setup(api => api.GetTranslation(It.IsAny <string>())).Returns(It.IsAny <string>());
            var pluginInitContext = new PluginInitContext()
            {
                API = mock.Object
            };
            var contextMenuLoader = new ContextMenuLoader(pluginInitContext);
            var searchResult      = new SearchResult()
            {
                Path = "C:/DummyFile.cs", Title = "DummyFile.cs"
            };
            var result = new Result()
            {
                ContextData = searchResult
            };

            // Act
            List <ContextMenuResult> contextMenuResults = contextMenuLoader.LoadContextMenus(result);

            // Assert
            Assert.AreEqual(contextMenuResults.Count, 3);
            mock.Verify(x => x.GetTranslation("Microsoft_plugin_indexer_copy_path"), Times.Once());
            mock.Verify(x => x.GetTranslation("Microsoft_plugin_indexer_open_containing_folder"), Times.Once());
            mock.Verify(x => x.GetTranslation("Microsoft_plugin_indexer_open_in_console"), Times.Once());
        }