public static MainWindowProxy OpenAndLogin(string userName, string password) { AutomationElement loginElement = FindOpenWindow("Welcome to Southwind"); Process process = null; if (loginElement == null) { process = Process.Start(@"D:\Signum\Southwind\Southwind.Windows\bin\Debug\Southwind.Windows.exe"); process.WaitForInputIdle(); loginElement = AutomationElement.RootElement.WaitChild(a => a.Current.ProcessId == process.Id && a.Current.ClassName == "Login", 5000); } var result = new MainWindowProxy(LoginWindowProxy.LoginAndContinue(loginElement, userName, password)); if (process != null) { result.Disposed += () => process.Kill(); } CultureInfoEntity culture = AuthLogic.RetrieveUser(userName).CultureInfo; Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = culture?.ToCultureInfo() ?? new CultureInfo("en-US"); return(result); }
public void OrderWindowsTestExample() { Lite <OrderEntity> lite = null; try { using (MainWindowProxy win = Common.OpenAndLogin("Normal", "Normal")) { using (SearchWindowProxy persons = win.SelectQuery(typeof(PersonEntity))) { persons.Search(); persons.SearchControl.SortColumn("Id", OrderType.Ascending); using (NormalWindowProxy <PersonEntity> john = persons.ViewElementAt <PersonEntity>(1)) { using (NormalWindowProxy <OrderEntity> order = john.ConstructFrom(OrderOperation.CreateOrderFromCustomer)) { order.ValueLineValue(a => a.ShipName, Guid.NewGuid().ToString()); order.EntityCombo(a => a.ShipVia).SelectToString("FedEx"); ProductEntity sonicProduct = Database.Query <ProductEntity>().SingleEx(p => p.ProductName.Contains("Sonic")); order.DetailGrid().AddRow(sonicProduct.ToLite()); Assert.AreEqual(sonicProduct.UnitPrice, order.ValueLineValue(a => a.TotalPrice)); order.Execute(OrderOperation.SaveNew); lite = order.Lite(); Assert.AreEqual(sonicProduct.UnitPrice, order.ValueLineValue(a => a.TotalPrice)); } } } using (NormalWindowProxy <OrderEntity> order = win.SelectEntity(lite)) { Assert.AreEqual(lite.InDB(a => a.TotalPrice), order.ValueLineValue(a => a.TotalPrice)); } } } finally { if (lite != null) { lite.Delete(); } } }//OrderWindowsTestExample