aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-04-22 15:58:38 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-04-22 15:58:38 +0300
commitfa5e1c45ab2da4e988cf256c0e5ec521288e537f (patch)
tree4ee0608e0382757f5a9ad7f7681c89b65691b20e /Software/Visual_Studio/Tango.UnitTesting
parentde099bd3b50b8ea52b212b8d322626582c2648be (diff)
downloadTango-fa5e1c45ab2da4e988cf256c0e5ec521288e537f.tar.gz
Tango-fa5e1c45ab2da4e988cf256c0e5ec521288e537f.zip
Implemented some UI test automation for Job create/delete.
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/DependencyInjection_TST.cs9
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs104
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj4
3 files changed, 112 insertions, 5 deletions
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<T>(this Window window, String id) where T : IUIItem
+ {
+ return window.Get<T>(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<Button>(SearchCriteria.ByText("LOGIN")) != null);
+ window.WaitTill(() => window.GetByAutomationId<Button>(UI.LoginButton) != null);
- var btnLogin = window.Get<Button>(SearchCriteria.ByText("LOGIN"));
+ var btnLogin = window.GetByAutomationId<Button>(UI.LoginButton);
Thread.Sleep(1000);
@@ -39,15 +79,69 @@ namespace Tango.UnitTesting
}
[TestMethod]
- public void Start_Developer_Module()
+ public void Start_Developer_Module_Create_And_Delete_Job()
{
+ Login();
+
var window = GetMachineStudioWindow();
window.WaitTill(() => window.Get<Button>(SearchCriteria.ByAutomationId("Developer")) != null);
- var btnDeveloper = window.Get<Button>(SearchCriteria.ByAutomationId("Developer"));
+ Wait(2000);
+
+ window.Get<Button>(SearchCriteria.ByAutomationId("Developer")).Click();
+
+ Wait();
+
+ window.GetByAutomationId<Button>(Developer.NewJobButton).Click();
+
+ Wait();
+
+ var jobsGrid = window.GetByAutomationId<ListView>(Developer.JobsDataGrid);
+ int jobsCount = jobsGrid.Items.Count;
+
+ var dialog = GetCurrentDialogWindow();
+
+ dialog.Keyboard.Enter("Unit Test Job");
+
+ Wait();
+
+ dialog.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN);
+
+ Assert.AreEqual(jobsCount, jobsGrid.Items.Count - 1);
+
+ Wait();
+
+ var segmentsListBox = window.GetByAutomationId<ListBox>(Developer.SegmentsListBox);
+ int segmentsCount = segmentsListBox.Items.Count;
+
+ window.GetByAutomationId<Button>(Developer.AddSegmentButton).Click();
+
+ Assert.AreEqual(segmentsCount, segmentsListBox.Items.Count - 1);
+
+ window.GetByAutomationId<ListBox>(Developer.SegmentsListBox).Items[1].Click();
+
+ window.GetByAutomationId<Button>(Developer.AddBrushStopButton).Click();
+
+ window.GetByAutomationId<Button>(Developer.AddBrushStopButton).Click();
+
+ window.GetByAutomationId<Button>(Developer.SaveJobButton).Click();
+
+ Wait(2000);
+
+ window.GetByAutomationId<Button>(Developer.ToJobsButton).Click();
+
+ ConfirmMessageBox();
+
+ Wait();
+
+ window.GetByAutomationId<Button>(Developer.DeleteJobButton).Click();
+
+ ConfirmMessageBox();
+
+ Assert.AreEqual(jobsCount, jobsGrid.Items.Count);
- btnDeveloper.Click();
+ Kill();
}
}
}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
index 03d3dc4a7..9a4e25264 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
+++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
@@ -107,6 +107,10 @@
<Project>{1674f726-0e66-414f-b9fd-c6f20d7f07c7}</Project>
<Name>Tango.MachineStudio.Logging</Name>
</ProjectReference>
+ <ProjectReference Include="..\MachineStudio\Tango.MachineStudio.Common\Tango.MachineStudio.Common.csproj">
+ <Project>{cb0b0aa2-bb24-4bca-a720-45e397684e12}</Project>
+ <Name>Tango.MachineStudio.Common</Name>
+ </ProjectReference>
<ProjectReference Include="..\Tango.BL\Tango.BL.csproj">
<Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project>
<Name>Tango.BL</Name>