public void Case_CheckAllKeysOnRelayController() { typeof(Hw.KbKeys).GetFields().ToList().ForEach((x) => { var v = (KeyPros)(x.GetValue("")); if (!v.Port.Equals("")) { try { TestIt.SendUsbKeyAndCheck(v, v.KeyCode); } catch (Exception e) { Console.WriteLine(e.Message); } } }); }
private void VerifyKeyWork(AT keyGridNeedToBeAssigned, string pressedKey) { var key = Hw.KbKeys.GetScKeyByUiaName(keyGridNeedToBeAssigned.GetElementInfo().Name()); DifferentFlowForDifferentPressedKey(pressedKey, () => { TestIt.SendUsbKeyAndCheck(key, null); }, () => { TestIt.SendUsbKeyAndCheck(key, key.KeyCode); }, () => { var f = typeof(MasterPlus.ReassignMenuItems.MediaKeysItems).GetFields().FirstOrDefault(x => x.GetValue("").Equals(pressedKey)); if (f != null) { var key1 = Hw.KbKeys.GetScKeyByVarName(f.Name); TestIt.SendUsbKeyAndCheck(key, key1.KeyCode); } else { TestIt.SendUsbKeyAndCheck(key, Hw.KbKeys.GetScKeyByUiaName(pressedKey).KeyCode); } }); }
static void Main(string[] args) { TestIt <string> .PrintProperty(s => s.Length); }
protected static bool DiscoverPesterTests(string source, TestDescribeCollection tests, IMessageLogger logger) { if (!File.Exists(source)) { return(false); } //SendMessage(TestMessageLevel.Informational, string.Format(Resources.SearchingForTestsFormat, source), logger); Token[] tokens; ParseError[] errors; ScriptBlockAst ast = Parser.ParseFile(source, out tokens, out errors); //if (errors.Any()) //{ // foreach (var error in errors) // { // SendMessage(TestMessageLevel.Error, string.Format(Resources.ParserErrorFormat, error.Message), logger); // } // return; //} IEnumerable <Ast> testSuites = ast.FindAll( m => (m is CommandAst) && string.Equals("describe", ((CommandAst)m).GetCommandName(), StringComparison.OrdinalIgnoreCase), true); foreach (Ast describeAst in testSuites) { string describeName = GetFunctionName(logger, describeAst, "describe"); Dictionary <string, TestContext> contextByName = new Dictionary <string, TestContext>(); //IEnumerable<string> tags = GetDescribeTags(logger, describeAst); IEnumerable <Ast> its = describeAst.FindAll(m => (m as CommandAst)?.GetCommandName()?.Equals("it", StringComparison.OrdinalIgnoreCase) == true, true); foreach (Ast test in its) { CommandAst itAst = (CommandAst)test; string itName = GetFunctionName(logger, test, "it"); string contextName = GetParentContextName(logger, test); if (!contextByName.TryGetValue(contextName, out TestContext context)) { context = new TestContext { Name = contextName, Path = source }; contextByName.Add(contextName, context); } // Didn't find the name for the test. Skip it. if (string.IsNullOrEmpty(itName)) { SendMessage(TestMessageLevel.Informational, "Test name was empty. Skipping test.", logger); continue; } TestIt it = new TestIt { Name = itName, Ast = itAst, Path = source, LineNr = itAst.Extent.StartLineNumber }; context.Its.Add(it); } if (contextByName.Count > 0) { TestDescribe describe = new TestDescribe { Name = describeName, Ast = describeAst, Path = source, LineNr = describeAst.Extent.StartLineNumber }; foreach (TestContext context in contextByName.Values) { describe.Contexts.Add(context); } tests.Add(describe); } } return(true); }