From fa5e1c45ab2da4e988cf256c0e5ec521288e537f Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 22 Apr 2018 15:58:38 +0300 Subject: Implemented some UI test automation for Job create/delete. --- .../Tango.UnitTesting/DependencyInjection_TST.cs | 9 ++ .../Tango.UnitTesting/MachineStudio_TST.cs | 104 ++++++++++++++++++++- .../Tango.UnitTesting/Tango.UnitTesting.csproj | 4 + 3 files changed, 112 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/Tango.UnitTesting') diff --git a/Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs index d1b888ed4..43e892351 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs @@ -25,10 +25,19 @@ namespace Tango.UnitTesting Assert.IsNotNull(vm.Service); Assert.IsNotNull(vm.DataProvider); Assert.IsNotNull(vm.Service.DataProvider); + Assert.IsNotNull(vm.GetDataProvider()); } public class ViewModel { + [TangoInject] + private IDataProvider _dataProvider; + + public IDataProvider GetDataProvider() + { + return _dataProvider; + } + public IService Service { get; set; } public IDataProvider DataProvider { get; set; } diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs index 7df8d59f9..827a41d80 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs @@ -5,14 +5,25 @@ 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 { + 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 @@ -24,14 +35,43 @@ namespace Tango.UnitTesting 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.Get