using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using Tango.MachineStudio.Common.Automation; using TestStack.White; using TestStack.White.Factory; using TestStack.White.UIItems; using TestStack.White.UIItems.Finders; using TestStack.White.UIItems.ListBoxItems; using TestStack.White.UIItems.WindowItems; using TestStack.White.WindowsAPI; namespace Tango.UnitTesting.MachineStudio { public static class AutomationExtensions { public static T GetByAutomationId(this Window window, String id) where T : IUIItem { return window.Get(SearchCriteria.ByAutomationId(id)); } } [TestClass] [TestCategory("Machine Studio")] public class MachineStudio_TST { private Window GetMachineStudioWindow() { var app = Application.AttachOrLaunch(new System.Diagnostics.ProcessStartInfo() { FileName = Helper.GetMachineStudioPath() }); var window = app.GetWindow("Tango", InitializeOption.NoCache); return window; } private Window GetCurrentDialogWindow() { var app = Application.AttachOrLaunch(new System.Diagnostics.ProcessStartInfo() { FileName = Helper.GetMachineStudioPath() }); return app.GetWindows().LastOrDefault(x => x.IsModal); } private void Kill(int delay = 4000) { Thread.Sleep(delay); var app = Application.AttachOrLaunch(new System.Diagnostics.ProcessStartInfo() { FileName = Helper.GetMachineStudioPath() }); app.Kill(); } private void Wait(int delay = 1000) { Thread.Sleep(delay); } private void ConfirmMessageBox() { Wait(); var dialog = GetCurrentDialogWindow(); if (dialog != null) { dialog.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN); } } [TestMethod] public void Login() { var window = GetMachineStudioWindow(); window.WaitTill(() => window.GetByAutomationId