/// <summary> /// Take a UIField, a delegate to resolve the UI widget value and a map of input->expected values and validates the results for a given field /// </summary> /// <param name="field"></param> /// <param name="collectValueFromWidget">A delegate to resolve the currently displayed widget value</param> /// <param name="valuesMap">A map of input to expected values</param> /// <returns></returns> public static Task ValidateAgainstValueMap(UIField field, ThemeConfig theme, Func <UIField, string> collectValueFromWidget, IEnumerable <ValueMap> valuesMap) { // *************** Enable to investigate/debug/develop new/existing tests ************************ bool investigateDebugTests = false; var perItemDelay = investigateDebugTests ? 1000 : 0; var testsWindow = new UIFieldTestWindow(500, 200, field, theme); return(testsWindow.RunTest((testRunner) => { foreach (var item in valuesMap) { testsWindow.SetAndValidateValues(item.ExpectedValue, item.InputValue, collectValueFromWidget, perItemDelay); } return Task.CompletedTask; }, 30)); }
/// <summary> /// Take a UIField, a delegate to resolve the UI widget value and a map of input->expected values and validates the results for a given field /// </summary> /// <param name="field"></param> /// <param name="collectValueFromWidget">A delegate to resolve the currently displayed widget value</param> /// <param name="valuesMap">A map of input to expected values</param> /// <returns></returns> public static Task ValidateAgainstValueMap(UIField field, Func <UIField, string> collectValueFromWidget, IEnumerable <ValueMap> valuesMap) { // *************** Enable to investigate/debug/develop new/existing tests ************************ bool investigateDebugTests = false; var perItemDelay = (investigateDebugTests) ? 500 : 0; var testsWindow = new UIFieldTestWindow(400, 200, field); return(testsWindow.RunTest((testRunner) => { var primaryFieldWidget = field.Content as MHNumberEdit; foreach (var item in valuesMap) { testsWindow.SetAndValidateValues(item.ExpectedValue, item.InputValue, collectValueFromWidget, perItemDelay); } return Task.CompletedTask; }, 30)); }