public void IsRegularExpression() { string expectedValue = @"\w*google"; ValidateCommand validateCommand = new ValidateCommand(); validateCommand.Arguments.Add(expectedValue); validateCommand.Arguments.Add("Text"); Assert.IsTrue(validateCommand.IsRegularExpression, "IsRegularExpression did not return the correct value."); validateCommand.Arguments.Clear(); validateCommand.Arguments.Add("not a reg ex."); validateCommand.Arguments.Add("Text"); Assert.IsFalse(validateCommand.IsRegularExpression, "IsRegularExpression did not return the correct value."); }
/// <summary> /// Responsible for creating instances or derived types of <see cref="Command" />, based on /// the value of <paramref name="type">command type</paramref>. /// </summary> /// <param name="type">MethodType of command to create</param> /// <returns>Command for the given <paramref name="type">command type</paramref></returns> private static Command Create(CommandType type) { Command returnValue = null; switch(type) { case CommandType.Back: case CommandType.BringToFront: case CommandType.Forward: case CommandType.Flash: case CommandType.Click: case CommandType.ClickNoWait: case CommandType.Refresh: case CommandType.DoubleClick: case CommandType.GoTo: case CommandType.Close: case CommandType.AttachToIE: case CommandType.PressTab: case CommandType.Focus: case CommandType.ClearCache: case CommandType.ClearCookies: case CommandType.Screenshot: case CommandType.SetCookie: case CommandType.GetCookie: returnValue = new Command(); break; case CommandType.AttachDialogHandler: case CommandType.GetJavaDialogMessage: returnValue = new DialogHandlerCommand(); break; case CommandType.Validate: case CommandType.ValidateItems: case CommandType.ValidateLastFound: returnValue = new ValidateCommand(); break; case CommandType.SetValue: case CommandType.SetValues: returnValue = new SetValueCommand(); break; case CommandType.AppendText: case CommandType.TypeText: case CommandType.ClearText: case CommandType.SelectText: returnValue = new TextFieldCommand(); break; case CommandType.Settings: returnValue = new SettingsCommand(); break; case CommandType.Code: returnValue = new CodeCommand(); break; default: throw new ArgumentOutOfRangeException("command", string.Format(CultureInfo.InvariantCulture, "Can not create a command object for unknown command type: {0}", type)); } return returnValue; }