2020-08-05 14:06:55 -07:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
2020-08-10 15:49:36 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Microsoft.Plugin.Folder;
|
2021-08-16 15:25:06 +02:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2020-08-05 14:06:55 -07:00
|
|
|
|
using Moq;
|
2020-07-08 09:56:26 -07:00
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Wox.Test.Plugins
|
|
|
|
|
|
{
|
2021-08-16 15:25:06 +02:00
|
|
|
|
[TestClass]
|
|
|
|
|
|
public class FolderPluginTest
|
2020-07-08 09:56:26 -07:00
|
|
|
|
{
|
2021-08-16 15:25:06 +02:00
|
|
|
|
[TestMethod]
|
|
|
|
|
|
public void ContextMenuLoaderReturnContextMenuForFolderWithOpenInConsoleWhenLoadContextMenusIsCalled()
|
2020-07-08 09:56:26 -07:00
|
|
|
|
{
|
2020-08-06 16:52:25 -07:00
|
|
|
|
// Arrange
|
2020-07-08 09:56:26 -07:00
|
|
|
|
var mock = new Mock<IPublicAPI>();
|
|
|
|
|
|
var pluginInitContext = new PluginInitContext() { API = mock.Object };
|
|
|
|
|
|
var contextMenuLoader = new ContextMenuLoader(pluginInitContext);
|
|
|
|
|
|
var searchResult = new SearchResult() { Type = ResultType.Folder, FullPath = "C:/DummyFolder" };
|
|
|
|
|
|
var result = new Result() { ContextData = searchResult };
|
|
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
|
List<ContextMenuResult> contextMenuResults = contextMenuLoader.LoadContextMenus(result);
|
|
|
|
|
|
|
|
|
|
|
|
// Assert
|
2020-10-07 22:12:59 +02:00
|
|
|
|
Assert.AreEqual(2, contextMenuResults.Count);
|
|
|
|
|
|
Assert.AreEqual(Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_copy_path, contextMenuResults[0].Title);
|
|
|
|
|
|
Assert.AreEqual(Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_open_in_console, contextMenuResults[1].Title);
|
2020-07-08 09:56:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-16 15:25:06 +02:00
|
|
|
|
[TestMethod]
|
|
|
|
|
|
public void ContextMenuLoaderReturnContextMenuForFileWithOpenInConsoleWhenLoadContextMenusIsCalled()
|
2020-07-08 09:56:26 -07:00
|
|
|
|
{
|
2020-08-06 16:52:25 -07:00
|
|
|
|
// Arrange
|
2020-07-08 09:56:26 -07:00
|
|
|
|
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
|
2020-10-07 22:12:59 +02:00
|
|
|
|
Assert.AreEqual(3, contextMenuResults.Count);
|
|
|
|
|
|
Assert.AreEqual(Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_open_containing_folder, contextMenuResults[0].Title);
|
|
|
|
|
|
Assert.AreEqual(Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_copy_path, contextMenuResults[1].Title);
|
|
|
|
|
|
Assert.AreEqual(Microsoft.Plugin.Folder.Properties.Resources.Microsoft_plugin_folder_open_in_console, contextMenuResults[2].Title);
|
2020-07-08 09:56:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|