private void PostSalesOrder(UserContext userContext, ClientLogicalForm newSalesOrderPage) { ClientLogicalForm postConfirmationDialog; using (new TestTransaction(TestContext, "Post")) { postConfirmationDialog = newSalesOrderPage.Action("Post...").InvokeCatchDialog(); } if (postConfirmationDialog == null) { userContext.ValidateForm(newSalesOrderPage); Assert.Inconclusive("Post dialog can't be found"); } using (new TestTransaction(TestContext, "ConfirmShipAndInvoice")) { ClientLogicalForm dialog = userContext.CatchDialog(postConfirmationDialog.Action("OK").Invoke); if (dialog != null) { // after confiming the post we dont expect more dialogs Assert.Fail("Unexpected Dialog on Post - Caption: {0} Message: {1}", dialog.Caption, dialog.FindMessage()); } } }
private void PostSalesOrder(UserContext userContext, ClientLogicalForm newSalesOrderPage) { ClientLogicalForm postConfirmationDialog; using (new TestTransaction(TestContext, "Post")) { postConfirmationDialog = newSalesOrderPage.Action("Post...").InvokeCatchDialog(); } if (postConfirmationDialog == null) { userContext.ValidateForm(newSalesOrderPage); Assert.Inconclusive("Post dialog can't be found"); } ClientLogicalForm openPostedInvoiceDialog; using (new TestTransaction(TestContext, "ConfirmShipAndInvoice")) { openPostedInvoiceDialog = userContext.CatchDialog(postConfirmationDialog.Action("OK").Invoke); } ClientLogicalForm postedInvoicePage; using (new TestTransaction(TestContext, "OpenPostedInvoice")) { if (openPostedInvoiceDialog != null) { postedInvoicePage = userContext.CatchForm(openPostedInvoiceDialog.Action("Yes").Invoke); var newSalesInvoiceNo = postedInvoicePage.Control("No.").StringValue; TestContext.WriteLine("Posted Sales Invoice No. {0}", newSalesInvoiceNo); TestScenario.ClosePage(TestContext, userContext, postedInvoicePage); } } }
/// <summary>"Catches" a new dialog opened (if any) during executions of <paramref name="action"/>.</summary> /// <param name="clientSession">The client Session.</param> /// <param name="action">The action.</param> /// <returns>The catch dialog. If no such dialog exists, returns null.</returns> public static ClientLogicalForm CatchDialog(this ClientSession clientSession, Action action) { ClientLogicalForm dialog = null; EventHandler <ClientDialogToShowEventArgs> clientSessionOnDialogToShow = (sender, args) => dialog = args.DialogToShow; bool wasSuspended = false; // If there is an instance of UnexpectedDialogHandler registered in the client session // make sure the UnexpectedDialogHandler is suspended while we catch a dialog UnexpectedDialogHandler unexpectedDialogHandler = GetUnexpectedDialogHandler(clientSession); if (unexpectedDialogHandler != null) { wasSuspended = unexpectedDialogHandler.IsSuspended; unexpectedDialogHandler.IsSuspended = true; } clientSession.DialogToShow += clientSessionOnDialogToShow; try { action(); } finally { clientSession.DialogToShow -= clientSessionOnDialogToShow; if (unexpectedDialogHandler != null) { unexpectedDialogHandler.IsSuspended = wasSuspended; } } return(dialog); }
private void AddPurchaseInvoiceLine( UserContext userContext, ClientLogicalForm purchaseInvoicePage, int index) { using (new TestTransaction(TestContext, "AddPurchaseInvoiceLine")) { var repeater = purchaseInvoicePage.Repeater(); var rowCount = repeater.Offset + repeater.DefaultViewport.Count; if (index >= rowCount) { // scroll to the next viewport userContext.InvokeInteraction( new ScrollRepeaterInteraction(repeater, 1)); } var rowIndex = (int)(index - repeater.Offset); var itemsLine = repeater.DefaultViewport[rowIndex]; // select random Item No. from lookup var itemNoControl = itemsLine.Control("Item No."); var itemNo = TestScenario.SelectRandomRecordFromLookup( TestContext, userContext, itemNoControl, "No."); TestScenario.SaveValueWithDelay(itemNoControl, itemNo); var qtyToOrder = SafeRandom.GetRandomNext(1, 10); TestScenario.SaveValueWithDelay(itemsLine.Control("Quantity"), qtyToOrder); } }
/// <summary> /// Open a form and closes the Cronus dialog if it is shown. If another dialog is shown this will throw an exception. /// </summary> /// <param name="clientSession">The <see cref="ClientSession"/>.</param> /// <param name="formId">The id of the form to open.</param> /// <returns>The form opened.</returns> /// <exception cref="InvalidOperationException">If a dialog is shown that is not the Cronus dialog.</exception> public static ClientLogicalForm OpenInitialForm(this ClientSession clientSession, string formId) { return(clientSession.CatchForm(delegate { ClientLogicalForm dialog = clientSession.CatchDialog( () => clientSession.InvokeInteraction(new OpenFormInteraction { Page = formId })); if (dialog != null) { if (ClientLogicalFormExtensions.IsCronusDemoDialog(dialog)) { clientSession.InvokeInteraction(new CloseFormInteraction(dialog)); } else { string exceptionMessage = "Unexpected dialog shown: " + dialog.Caption; ClientStaticStringControl staticStringControl = dialog.ContainedControls.OfType <ClientStaticStringControl>().FirstOrDefault(); if (staticStringControl != null) { exceptionMessage += " - " + staticStringControl.StringValue; } throw new InvalidOperationException(exceptionMessage); } } })); }
private void PostSalesOrder(UserContext userContext, ClientLogicalForm newSalesOrderPage) { ClientLogicalForm postConfirmationDialog; using (new TestTransaction(TestContext, "Post")) { postConfirmationDialog = newSalesOrderPage.Action("Post...").InvokeCatchDialog(); } if (postConfirmationDialog == null) { userContext.ValidateForm(newSalesOrderPage); Assert.Inconclusive("Post dialog can't be found"); } using (new TestTransaction(TestContext, "ConfirmShipAndInvoice")) { ClientLogicalForm dialog = userContext.CatchDialog(postConfirmationDialog.Action("OK").Invoke); if (dialog != null) { // The order has been posted and moved to the posted invoices tab, do you want to open... dialog.Action("No").Invoke(); } } }
private void AddSalesOrderLine(UserContext userContext, ClientLogicalForm newSalesOrderPage, int index) { var repeater = newSalesOrderPage.Repeater(); var rowCount = repeater.Offset + repeater.DefaultViewport.Count; if (index >= rowCount) { // scroll to the next viewport userContext.InvokeInteraction(new ScrollRepeaterInteraction(repeater, 1)); } var rowIndex = (int)(index - repeater.Offset); var itemsLine = repeater.DefaultViewport[rowIndex]; // Activate Type field itemsLine.Control("Type").Activate(); // set Type = Item TestScenario.SaveValueWithDelay(itemsLine.Control("Type"), "Item"); // Set Item No. from random lookup var itemNoControl = itemsLine.Control("No."); var itemNo = TestScenario.SelectRandomRecordFromLookup(TestContext, userContext, itemNoControl, "No."); TestScenario.SaveValueWithDelay(itemNoControl, itemNo); var qtyToOrder = SafeRandom.GetRandomNext(1, 10).ToString(CultureInfo.InvariantCulture); TestScenario.SaveValueAndIgnoreWarning(TestContext, userContext, itemsLine.Control("Quantity"), qtyToOrder); TestScenario.SaveValueAndIgnoreWarning(TestContext, userContext, itemsLine.Control("Qty. to Ship"), qtyToOrder, "OK"); // Look at the line for 1 seconds. DelayTiming.SleepDelay(DelayTiming.ThinkDelay); }
private void AddSalesOrderLine(UserContext userContext, ClientLogicalForm newSalesOrderPage, int line) { // Get Line var itemsLine = newSalesOrderPage.Repeater().DefaultViewport[line]; // Activate Type field itemsLine.Control("Type").Activate(); // set Type = Item TestScenario.SaveValueWithDelay(itemsLine.Control("Type"), "Item"); // Set Item No. var itemNo = TestScenario.SelectRandomRecordFromListPage(TestContext, ItemListPageId, userContext, "No."); TestScenario.SaveValueWithDelay(itemsLine.Control("No."), itemNo); string qtyToOrder = SafeRandom.GetRandomNext(1, 10).ToString(CultureInfo.InvariantCulture); TestScenario.SaveValueAndIgnoreWarning(TestContext, userContext, itemsLine.Control("Quantity"), qtyToOrder); TestScenario.SaveValueAndIgnoreWarning(TestContext, userContext, itemsLine.Control("Qty. to Ship"), qtyToOrder, "OK"); // Look at the line for 1 seconds. DelayTiming.SleepDelay(DelayTiming.ThinkDelay); }
internal static void DisableInterfaces(UserContext userContext, ClientLogicalForm Page) { Page.Activate(); Page.Control("Editable").Activate(); Page.Control("Editable").SaveValue(false); Page.Control("Show").Activate(); Page.Control("Show").SaveValue(false); }
/// <summary> /// Handles client logical dialog. /// </summary> /// <param name="dialog"> /// The dialog. /// </param> public void HandleDialog(ClientLogicalForm dialog) { if (this.IsSuspended) { return; } this.handleDialog(dialog); }
public static void ClosePage(TestContext testContext, UserContext context, ClientLogicalForm form) { if (form.State == ClientLogicalFormState.Open) { using (new TestTransaction(testContext, String.Format("ClosePage{0}", UserContext.GetActualPageNo(form)))) { context.InvokeInteraction(new CloseFormInteraction(form)); } } }
internal static void EnableInterfaces(UserContext userContext, ClientLogicalForm Page) { Page.Activate(); Page.Control("Editable").Activate(); Page.Control("Editable").SaveValue(true); Page.Control("Show").Activate(); Page.Control("Show").SaveValue(true); Page.Control("Clear on Submit").Activate(); Page.Control("Clear on Submit").SaveValue(true); }
public ClientLogicalForm EnsurePage(int expectedPageNo, ClientLogicalForm page) { if (expectedPageNo == 0) { if (page != null) { if (page.ControlIdentifier.Equals("00000000-0000-0000-0800-0000836bd2d2")) { throw new Exception("ERROR: " + page.Children[0].Children[0].Children[1].Caption.Replace( Environment.NewLine, " ")); } var actualPageNo = GetActualPageNo(page); if (actualPageNo != expectedPageNo) { throw new Exception(String.Format("Not expecting any page to open, but got Page No. {0}", actualPageNo)); } } } else { if (page == null) { throw new Exception(String.Format("Expecting Page No. {0} to open, instead no page was opened", expectedPageNo)); } if (page.ControlIdentifier.Equals("00000000-0000-0000-0800-0000836bd2d2")) { throw new Exception("ERROR: " + page.Children[0].Children[0].Children[1].Caption.Replace(Environment.NewLine, " ")); } int actualPageNo; try { actualPageNo = GetActualPageNo(page); } catch { throw new Exception( String.Format( "Expecting Page No. {0} to open, instead got a page with ControlIdentifier={1}, Caption={2}", expectedPageNo, page.ControlIdentifier, page.Caption)); } if (actualPageNo != expectedPageNo) { throw new Exception(String.Format("Expecting Page No. {0} to open, instead got Page No. {1}", expectedPageNo, actualPageNo)); } } return(page); }
public static string SelectRandomRecord( ClientLogicalForm form, string keyFieldCaption) { // selects a random row from the repeater var rowCount = form.Repeater().DefaultViewport.Count; var rowToSelect = SafeRandom.GetRandomNext(rowCount); var rowControl = form.Repeater().DefaultViewport[rowToSelect]; var randomKey = rowControl.Control(keyFieldCaption).StringValue; return(randomKey); }
/// <summary> /// Determines whether [is cronus demo dialog] [the specified dialog]. /// </summary> /// <param name="dialog">The dialog.</param> /// <returns> /// <c>true</c> if [is cronus demo dialog] [the specified dialog]; otherwise, <c>false</c>. /// </returns> public static bool IsCronusDemoDialog(ClientLogicalForm dialog) { if (dialog.IsDialog) { ClientStaticStringControl staticStringControl = dialog.ContainedControls.OfType <ClientStaticStringControl>().FirstOrDefault(); if (staticStringControl != null && staticStringControl.StringValue != null) { return(staticStringControl.StringValue.ToUpperInvariant().Contains("CRONUS")); } } return(false); }
public static void ClosePage(TestContext testContext, UserContext context, ClientLogicalForm form) { if (form.State == ClientLogicalFormState.Open) { using (new TestTransaction(testContext, $"ClosePage{UserContext.GetActualPageNo(form)}")) { InvokeActionAndCloseAnyDialog( testContext, context, () => context.InvokeInteraction(new CloseFormInteraction(form))); } } }
public void ValidateForm(ClientLogicalForm form) { ObservableCollection <ClientValidationResultItem> prevalidate = form.ValidationResults; if (prevalidate.Count == 0) { return; } foreach (ClientValidationResultItem clientValidationResultItem in prevalidate) { throw new Exception(clientValidationResultItem.Description); } }
public static void ExecuteQuickFilter(this ClientLogicalForm form, string columnName, string value) { var filter = form.FindLogicalFormControl <ClientFilterLogicalControl>(); form.Session.InvokeInteraction(new ExecuteFilterInteraction(filter) { QuickFilterColumnId = filter.QuickFilterColumns.First(columnDef => columnDef.Caption.Replace("&", "").Equals(columnName)).Id, QuickFilterValue = value }); if (filter.ValidationResults.Count > 0) { throw new ArgumentException("Could not execute filter."); } }
/// <summary>"Catches" a new form opened (if any) during executions of <paramref name="action"/>.</summary> /// <param name="clientSession">The client Session.</param> /// <param name="action">The action.</param> /// <returns>The catch form. If no such form exists, returns null.</returns> public static ClientLogicalForm CatchForm(this ClientSession clientSession, Action action) { ClientLogicalForm form = null; EventHandler <ClientFormToShowEventArgs> clientSessionOnFormToShow = delegate(object sender, ClientFormToShowEventArgs args) { form = args.FormToShow; }; clientSession.FormToShow += clientSessionOnFormToShow; try { action(); } finally { clientSession.FormToShow -= clientSessionOnFormToShow; } return(form); }
public static int GetActualPageNo(ClientLogicalForm form) { int actualPageNo; try { actualPageNo = Convert.ToInt32(form.ControlIdentifier.Substring(1, 8), 16); } catch { throw new Exception( String.Format( "Not expecting any page to open, but got a page with ControlIdentifier={0}, Caption={1}", form.ControlIdentifier, form.Caption)); } return(actualPageNo); }
private void PostPurchaseInvoice( UserContext userContext, ClientLogicalForm purchaseInvoicePage) { ClientLogicalForm openPostedInvoiceDialog; using (new TestTransaction(TestContext, "Post")) { var postConfirmationDialog = purchaseInvoicePage.Action("Post") .InvokeCatchDialog(); if (postConfirmationDialog == null) { userContext.ValidateForm(purchaseInvoicePage); Assert.Fail("Confirm Post dialog not found"); } openPostedInvoiceDialog = postConfirmationDialog.Action("Yes") .InvokeCatchDialog(); } if (openPostedInvoiceDialog == null) { Assert.Fail("Open Posted Invoice dialog not found"); } ClientLogicalForm postedPurchaseInvoicePage; using (new TestTransaction(TestContext, "OpenPostedPurchaseInvoice")) { postedPurchaseInvoicePage = userContext.EnsurePage( PostedPurchaseInvoiceCard, openPostedInvoiceDialog.Action("Yes").InvokeCatchForm()); } TestContext.WriteLine( "Posted Purchase Invoice {0}", postedPurchaseInvoicePage.Caption); TestScenario.ClosePage( TestContext, userContext, postedPurchaseInvoicePage); }
public static string FindMessage(this ClientLogicalForm form) { return(form.ContainedControls.OfType <ClientStaticStringControl>().First().StringValue); }
public void ValidateForm(ClientLogicalForm form) { ObservableCollection<ClientValidationResultItem> prevalidate = form.ValidationResults; if (prevalidate.Count == 0) { return; } foreach (ClientValidationResultItem clientValidationResultItem in prevalidate) { throw new Exception(clientValidationResultItem.Description); } }
public static int GetActualPageNo(ClientLogicalForm form) { int actualPageNo; try { actualPageNo = Convert.ToInt32(form.ControlIdentifier.Substring(1, 8), 16); } catch { throw new Exception( String.Format( "Not expecting any page to open, but got a page with ControlIdentifier={0}, Caption={1}", form.ControlIdentifier, form.Caption)); } return actualPageNo; }
private void AddPurchaseInvoiceLine( UserContext userContext, ClientLogicalForm purchaseInvoicePage, int index) { using (new TestTransaction(TestContext, "AddPurchaseInvoiceLine")) { var repeater = purchaseInvoicePage.Repeater(); var rowCount = repeater.Offset + repeater.DefaultViewport.Count; if (index >= rowCount) { // scroll to the next viewport userContext.InvokeInteraction( new ScrollRepeaterInteraction(repeater, 1)); } var rowIndex = (int) (index - repeater.Offset); var itemsLine = repeater.DefaultViewport[rowIndex]; // select random Item No. from lookup var itemNoControl = itemsLine.Control("Item No."); var itemNo = TestScenario.SelectRandomRecordFromLookup( TestContext, userContext, itemNoControl, "No."); TestScenario.SaveValueWithDelay(itemNoControl, itemNo); var qtyToOrder = SafeRandom.GetRandomNext(1, 10); TestScenario.SaveValueWithDelay(itemsLine.Control("Quantity"), qtyToOrder); } }
public static TType FindLogicalFormControl <TType>(this ClientLogicalForm form, string controlCaption = null) { return(form.ContainedControls.OfType <TType>().First()); }
public ClientLogicalForm EnsurePage(int expectedPageNo, ClientLogicalForm page) { if (expectedPageNo == 0) { if (page != null) { if (page.ControlIdentifier.Equals("00000000-0000-0000-0800-0000836bd2d2")) { throw new Exception("ERROR: " + page.Children[0].Children[0].Children[1].Caption.Replace( Environment.NewLine, " ")); } var actualPageNo = GetActualPageNo(page); if (actualPageNo != expectedPageNo) { throw new Exception(String.Format("Not expecting any page to open, but got Page No. {0}", actualPageNo)); } } } else { if (page == null) { throw new Exception(String.Format("Expecting Page No. {0} to open, instead no page was opened", expectedPageNo)); } if (page.ControlIdentifier.Equals("00000000-0000-0000-0800-0000836bd2d2")) { throw new Exception("ERROR: " + page.Children[0].Children[0].Children[1].Caption.Replace(Environment.NewLine, " ")); } int actualPageNo; try { actualPageNo = GetActualPageNo(page); } catch { throw new Exception( String.Format( "Expecting Page No. {0} to open, instead got a page with ControlIdentifier={1}, Caption={2}", expectedPageNo, page.ControlIdentifier, page.Caption)); } if (actualPageNo != expectedPageNo) { throw new Exception(String.Format("Expecting Page No. {0} to open, instead got Page No. {1}", expectedPageNo, actualPageNo)); } } return page; }
public static ClientRepeaterControl Repeater(this ClientLogicalForm form) { return(form.ContainedControls.OfType <ClientRepeaterControl>().First()); }
public static string SelectRandomRecord( ClientLogicalForm form, string keyFieldCaption) { // selects a random row from the repeater var rowCount = form.Repeater().DefaultViewport.Count; var rowToSelect = SafeRandom.GetRandomNext(rowCount); var rowControl = form.Repeater().DefaultViewport[rowToSelect]; var randomKey = rowControl.Control(keyFieldCaption).StringValue; return randomKey; }