ICmdReprParsableTests.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Microsoft.PowerToys.Settings.UI.Library; 6 using Microsoft.VisualStudio.TestTools.UnitTesting; 7 8 namespace Settings.UI.UnitTests.Settings; 9 10 [TestClass] 11 public class ICmdReprParsableTests 12 { 13 [TestMethod] 14 public void KeyboardKeysPropertyParsing() 15 { 16 { 17 Assert.IsTrue(KeyboardKeysProperty.TryParseFromCmd("win+ctrl+Alt+sHifT+Q", out var hotkey)); 18 19 Assert.AreEqual(new KeyboardKeysProperty { Value = new HotkeySettings(true, true, true, true, 0x51) }, hotkey); 20 } 21 22 { 23 Assert.IsTrue(KeyboardKeysProperty.TryParseFromCmd("CTRL+z", out var hotkey)); 24 Assert.AreEqual(new KeyboardKeysProperty { Value = new HotkeySettings(false, true, false, false, 0x5A) }, hotkey); 25 } 26 27 { 28 Assert.IsTrue(KeyboardKeysProperty.TryParseFromCmd("shift+ALT+0x59", out var hotkey)); 29 Assert.AreEqual(new KeyboardKeysProperty { Value = new HotkeySettings(false, false, true, true, 0x59) }, hotkey); 30 } 31 32 { 33 Assert.IsTrue(KeyboardKeysProperty.TryParseFromCmd("alt+Space", out var hotkey)); 34 Assert.AreEqual(new KeyboardKeysProperty { Value = new HotkeySettings(false, false, true, false, 0x20) }, hotkey); 35 } 36 } 37 38 [TestMethod] 39 public void BoolPropertyParsing() 40 { 41 { 42 Assert.IsTrue(BoolProperty.TryParseFromCmd("True", out var result)); 43 Assert.AreEqual(new BoolProperty(true), result); 44 } 45 46 { 47 Assert.IsTrue(BoolProperty.TryParseFromCmd("false", out var result)); 48 Assert.AreEqual(new BoolProperty(false), result); 49 } 50 } 51 52 [TestMethod] 53 public void IntPropertyParsing() 54 { 55 { 56 Assert.IsTrue(IntProperty.TryParseFromCmd("123", out var result)); 57 Assert.AreEqual(new IntProperty(123), result); 58 } 59 60 { 61 Assert.IsTrue(IntProperty.TryParseFromCmd("1500", out var result)); 62 Assert.AreEqual(new IntProperty(1500), result); 63 Assert.AreNotEqual(new IntProperty(15), result); 64 } 65 } 66 67 [TestMethod] 68 public void MouseJumpThumbnailSizeParsing() 69 { 70 { 71 Assert.IsTrue(MouseJumpThumbnailSize.TryParseFromCmd("1920x1080", out var result)); 72 Assert.AreEqual(new MouseJumpThumbnailSize { Width = 1920, Height = 1080 }, result); 73 } 74 } 75 }