mirror of
https://github.com/bolucat/Archive.git
synced 2025-11-03 11:02:18 +08:00
46 lines
2.5 KiB
C#
Executable File
46 lines
2.5 KiB
C#
Executable File
using System;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Shadowsocks.Controller;
|
|
using GlobalHotKey;
|
|
using System.Windows.Input;
|
|
using System.Threading;
|
|
using System.Collections.Generic;
|
|
using Shadowsocks.Controller.Hotkeys;
|
|
using System.Diagnostics;
|
|
|
|
|
|
namespace Shadowsocks.Test
|
|
{
|
|
[TestClass]
|
|
public class UnitTest
|
|
{
|
|
[TestMethod]
|
|
public void TestHotKey2Str()
|
|
{
|
|
Assert.AreEqual("Ctrl+A", HotKeys.HotKey2Str(Key.A, ModifierKeys.Control));
|
|
Assert.AreEqual("Ctrl+Alt+D2", HotKeys.HotKey2Str(Key.D2, (ModifierKeys.Alt | ModifierKeys.Control)));
|
|
Assert.AreEqual("Ctrl+Alt+Shift+NumPad7", HotKeys.HotKey2Str(Key.NumPad7, (ModifierKeys.Alt | ModifierKeys.Control | ModifierKeys.Shift)));
|
|
Assert.AreEqual("Ctrl+Alt+Shift+F6", HotKeys.HotKey2Str(Key.F6, (ModifierKeys.Alt | ModifierKeys.Control | ModifierKeys.Shift)));
|
|
Assert.AreNotEqual("Ctrl+Shift+Alt+F6", HotKeys.HotKey2Str(Key.F6, (ModifierKeys.Alt | ModifierKeys.Control | ModifierKeys.Shift)));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestStr2HotKey()
|
|
{
|
|
Assert.IsTrue(HotKeys.Str2HotKey("Ctrl+A").Equals(new HotKey(Key.A, ModifierKeys.Control)));
|
|
Assert.IsTrue(HotKeys.Str2HotKey("Ctrl+Alt+A").Equals(new HotKey(Key.A, (ModifierKeys.Control | ModifierKeys.Alt))));
|
|
Assert.IsTrue(HotKeys.Str2HotKey("Ctrl+Shift+A").Equals(new HotKey(Key.A, (ModifierKeys.Control | ModifierKeys.Shift))));
|
|
Assert.IsTrue(HotKeys.Str2HotKey("Ctrl+Alt+Shift+A").Equals(new HotKey(Key.A, (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift))));
|
|
HotKey testKey0 = HotKeys.Str2HotKey("Ctrl+Alt+Shift+A");
|
|
Assert.IsTrue(testKey0 != null && testKey0.Equals(new HotKey(Key.A, (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift))));
|
|
HotKey testKey1 = HotKeys.Str2HotKey("Ctrl+Alt+Shift+F2");
|
|
Assert.IsTrue(testKey1 != null && testKey1.Equals(new HotKey(Key.F2, (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift))));
|
|
HotKey testKey2 = HotKeys.Str2HotKey("Ctrl+Shift+Alt+D7");
|
|
Assert.IsTrue(testKey2 != null && testKey2.Equals(new HotKey(Key.D7, (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift))));
|
|
HotKey testKey3 = HotKeys.Str2HotKey("Ctrl+Shift+Alt+NumPad7");
|
|
Assert.IsTrue(testKey3 != null && testKey3.Equals(new HotKey(Key.NumPad7, (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift))));
|
|
}
|
|
|
|
}
|
|
}
|