aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Test_Studio/Machine Studio/Shared/Launch Or Attache To Machine Studio.tstest.cs
blob: b7331ce8bc75299fe7e2280ba5d80d08d0a3a4bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Telerik.WebAii.Controls.Xaml.Wpf;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

using ArtOfTest.Common.UnitTesting;
using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.Controls.HtmlControls;
using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
using ArtOfTest.WebAii.Design;
using ArtOfTest.WebAii.Design.Execution;
using ArtOfTest.WebAii.ObjectModel;
using ArtOfTest.WebAii.Silverlight;
using ArtOfTest.WebAii.Silverlight.UI;
using ArtOfTest.WebAii.Wpf;

namespace Machine_Studio
{
    public class Attache_To_Machine_Studio : BaseWebAiiTest
    {
        #region [ Dynamic Applications Reference ]

        private Applications _applications;

        /// <summary>
        /// Gets the Applications object that has references
        /// to all the elements, windows or regions
        /// in this project.
        /// </summary>
        public Applications Applications
        {
            get
            {
                if (_applications == null)
                {
                    _applications = new Applications(Manager.Current);
                }
                return _applications;
            }
        }

        #endregion
        
        // Add your test methods here...
    
        [CodedStep(@"New Coded Step")]
        public void Attache_To_Machine_Studio_CodedStep()
        {
            Manager.Log.WriteLine("Looking for existing machine studio instance..");
            
            var runningApp = System.Diagnostics.Process.GetProcesses().Where(p => p.ProcessName == "Tango.MachineStudio.UI");
            
            if (runningApp.Count() != 0)
            {
                Manager.Log.WriteLine("Found Machine Studio Instance. Connecting...");
                Manager.ConnectToApplication(runningApp.FirstOrDefault());
            }
            else
            {
                Manager.Log.WriteLine("Instance not found. Launching new instance...");
                Manager.LaunchNewApplication("..\\..\\Visual_Studio\\Build\\Machine Studio\\Release\\Tango.MachineStudio.UI.exe");
            }
            
            Manager.ActiveApplication.MainWindow.RefreshVisualTrees();
        }
    }
}