public void AutoSwitchingTest() { var path = AppDomain.CurrentDomain.BaseDirectory; Debug.WriteLine($"Current path is {path}"); var app = Process.Start($"{path}\\..\\Release\\AutoMova.exe"); app.WaitForInputIdle(); var notepad = Process.Start("notepad.exe"); notepad.WaitForInputIdle(); var layouts = LowLevelAdapter.GetLayoutList(); var inputLangCollection = InputLanguage.InstalledInputLanguages; InputLanguage[] langs = new InputLanguage[layouts.Length]; inputLangCollection.CopyTo(langs, 0); Dictionary <IntPtr, string[]> testStrings = new Dictionary <IntPtr, string[]>(); foreach (var lang in langs) { testStrings.Add(layouts[Array.IndexOf(langs, lang)], System.IO.File.ReadAllLines($"{path}\\..\\..\\Test\\data\\{lang.Culture.Name.Substring(0,2)}.txt")); } string expectedString = ""; List <List <Keys> > testKeyCodes = new List <List <Keys> >(); foreach (var layout in testStrings.Keys) { foreach (var str in testStrings[layout]) { expectedString += (str + " "); PressKeys(StringToKeys(str, layout)); } } LowLevelAdapter.SendSelectAll(); LowLevelAdapter.SendCopy(); LowLevelAdapter.SendKeyPress(Keys.Delete); notepad.CloseMainWindow(); notepad.Close(); app.Kill(); var actualString = Clipboard.GetText(); var expectedWords = expectedString.Split(' '); var actualWords = actualString.Split(' '); for (int i = 0; i < expectedWords.Length; i++) { if (expectedWords[i] != actualWords[i]) { Debug.WriteLine($"{expectedWords[i]} -> {actualWords[i]}"); } } Assert.AreEqual(expectedWords, actualWords, "Auto switching error"); }