mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[Run] Open in console functionality (#4739)
* Added open in console for indexer * Added open in console fpr indexer and folder plugin * Added open in console to program plugin * Added string localization for program plugin * Added test for win32 program * Added test for win32 programs * Added test for indexer plugin * Localization for context menu title * Added tests for folder plugin * Added tests for indexer plugin * Code cleanup * Improved logging and nit fixes * Updated tooltip for open in console * Updates tests * Removed subtitle property from contextmenuresult class * Improved logging for context menu loaders
This commit is contained in:
committed by
GitHub
parent
e3e6b23b7c
commit
638cd1dd48
@@ -7,6 +7,8 @@ using Microsoft.Plugin.Indexer.SearchHelper;
|
||||
using Microsoft.Plugin.Indexer.Interface;
|
||||
using Moq;
|
||||
using System.Linq;
|
||||
using Microsoft.Plugin.Indexer;
|
||||
using Wox.Plugin;
|
||||
|
||||
namespace Wox.Test.Plugins
|
||||
{
|
||||
@@ -214,5 +216,46 @@ namespace Wox.Test.Plugins
|
||||
Assert.IsFalse(windowsSearchAPIResults.Any(x => x.Title == "file1.txt"));
|
||||
Assert.IsTrue(windowsSearchAPIResults.Any(x => x.Title == "file2.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ContextMenuLoader_ReturnContextMenuForFolderWithOpenInConsole_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:/DummyFolder", Title = "DummyFolder" };
|
||||
var result = new Result() { ContextData = searchResult };
|
||||
|
||||
// Act
|
||||
List<ContextMenuResult> contextMenuResults = contextMenuLoader.LoadContextMenus(result);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(contextMenuResults.Count, 2);
|
||||
mock.Verify(x => x.GetTranslation("Microsoft_plugin_indexer_copy_path"), Times.Once());
|
||||
mock.Verify(x => x.GetTranslation("Microsoft_plugin_indexer_open_in_console"), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user