The CommonCmdletBase class in the top of cmdlet hierarchy.
Наследование: PSTestLib.PSCmdletBase
        private void getAndConditions(string name, string automationId, string className, string controlType)
        {
            ResultAndCondition = null;
            
            var cmdlet =
                new GetControlCmdletBase {Name = name, AutomationId = automationId, Class = className, CaseSensitive = false };

            var common =
                new CommonCmdletBase();
            
            // 20131128
            //ResultAndCondition =
            //    (common.GetControlConditionsForWildcardSearch(cmdlet, controlType, cmdlet.CaseSensitive, true) as AndCondition);
            // 20131129
            // ResultAndCondition =
            //     (common.GetControlConditionsForWildcardSearch(cmdlet, controlType, cmdlet.CaseSensitive));
            ResultAndCondition =
                // common.GetWildcardSearchCondition(cmdlet) as AndCondition;
                ControlSearcher.GetWildcardSearchCondition(
                    new ControlSearcherData {
                        Name = name,
                        AutomationId = automationId,
                        Class = className,
                        CaseSensitive = false
                    }) as AndCondition;
        }
Пример #2
0
        protected internal void WriteDebug(CommonCmdletBase cmdlet, object obj)
        {
            string reportString =
                CmdletSignature(cmdlet) +
                obj;

            WriteLog(LogLevels.Debug, reportString);
        }
Пример #3
0
        protected internal void WriteWarn(CommonCmdletBase cmdlet, string text)
        {
            string reportString =
                CmdletSignature(cmdlet) +
                text;

            // 20140317
            // turning off the logger
            // Logger.Warn(reportString);
        }
Пример #4
0
 internal static T GetCommand <T>(CommonCmdletBase cmdlet)
 {
     try {
         T   newCommand  = default(T);
         var cmdletParam = new ConstructorArgument("cmdlet", cmdlet);
         newCommand = Kernel.Get <T>(cmdletParam);
         return(ConvertToProxiedCommand <T>(newCommand, cmdlet));
     } catch (Exception) {
         // TODO
         // write error to error object!!!
         // Console.WriteLine("Command 01");
         // Console.WriteLine(eCommand.Message);
         return(default(T));
     }
 }
Пример #5
0
 internal virtual string GetObjectPropertiesInfo(CommonCmdletBase cmdlet)
 {
     string result = string.Empty;
     
     // http://stackoverflow.com/questions/2281972/how-to-get-a-list-of-properties-with-a-given-attribute
     foreach (PropertyInfo propertyInfo in cmdlet.GetType()
              .GetProperties(BindingFlags.Public | BindingFlags.Instance)
              .Where(p => p.GetCustomAttributes(typeof(UiaParameterAttribute), true).Length != 0)) {
         
         result += GetPropertyString(cmdlet, propertyInfo);
     }
     
     result = cmdlet.CmdletName(cmdlet) + result;
     
     return result;
 }
Пример #6
0
        internal virtual string GetObjectPropertiesInfo(CommonCmdletBase cmdlet)
        {
            string result = string.Empty;

            // http://stackoverflow.com/questions/2281972/how-to-get-a-list-of-properties-with-a-given-attribute
            foreach (PropertyInfo propertyInfo in cmdlet.GetType()
                     .GetProperties(BindingFlags.Public | BindingFlags.Instance)
                     .Where(p => p.GetCustomAttributes(typeof(UiaParameterAttribute), true).Length != 0))
            {
                result += GetPropertyString(cmdlet, propertyInfo);
            }

            result = cmdlet.CmdletName(cmdlet) + result;

            return(result);
        }
        private void getOrConditions(string searchString, string controlType)
        {
            ResultOrCondition = null;
            
            GetControlCmdletBase cmdlet =
                new GetControlCmdletBase {ContainsText = searchString };

            CommonCmdletBase common =
                new CommonCmdletBase();
            
            // 20131129
            // ResultOrCondition =
            //     (common.GetControlConditionsForExactSearch(cmdlet, controlType, cmdlet.CaseSensitive, false) as OrCondition);
            ResultOrCondition =
                // common.GetTextSearchCondition(searchString, new string[] { controlType }, cmdlet.CaseSensitive) as OrCondition;
                ControlSearcher.GetTextSearchCondition(searchString, new string[] { controlType }, cmdlet.CaseSensitive) as OrCondition;
        }
 private void checkConditionsArray(
     string controlType,
     string controlTypeProperty,
     string controlTypeValue)
 {
     Condition[] conditions = null;
     cmdlet = 
         new UIAutomation.Commands.GetUiaControlCommand();
     cmdletBase = 
         new GetControlCmdletBase();
     
     Condition condition =
         // cmdlet.GetWildcardSearchCondition(cmdlet);
         ControlSearcher.GetWildcardSearchCondition(
             new ControlSearcherData {
                 // completely new
                 Name = cmdlet.Name,
                 AutomationId = cmdlet.AutomationId,
                 Class = cmdlet.Class,
                 Value = cmdlet.Value,
                 ControlType = cmdlet.ControlType
             });
     // 20140630
     // conditions = ((AndCondition)condition).GetConditions();
     if (null != condition as AndCondition) {
         conditions = ((AndCondition)condition).GetConditions();
     } else if (null != condition as OrCondition) {
         conditions = ((OrCondition)condition).GetConditions();
     } else {
         conditions = new[] { condition };
     }
     
     foreach (Condition cond in conditions) {
         if ((cond as PropertyCondition) != null) {
             MbUnit.Framework.Assert.AreEqual(
                 controlTypeProperty, 
                 (cond as PropertyCondition).Property.ProgrammaticName);
             MbUnit.Framework.Assert.AreEqual(
                 controlTypeValue, 
                 (cond as PropertyCondition).Value.ToString());
         } else {
             MbUnit.Framework.Assert.AreEqual(cond, Condition.TrueCondition);
         }
     }
 }
Пример #9
0
        internal static T ConvertToProxiedCommand <T>(T commandToConvert, CommonCmdletBase cmdlet)
        {
            T proxiedObject = default(T);

            try {
                proxiedObject =
                    (T)_generator.CreateClassProxy(
                        typeof(T),
                        new CommonCmdletBase[] { cmdlet },
                        // 20140228
                        // new LoggingAspect(), new InputValidationAspect(), new ErrorHandlingAspect(), new HighlighterAspect(), new TestResultAspect());
                        new LoggingAspect(), new InputValidationAspect(), new ErrorHandlingAspect(), new HighlighterAspect(), new TestResultAspect(), new FaultInjectionAspect());
            } catch (Exception) {
                // Console.WriteLine("ProxiedObject");
                // Console.WriteLine(eProxying.Message);
            }

            return(proxiedObject);
        }
Пример #10
0
        protected internal void WriteInfo(CommonCmdletBase cmdlet, string text)
        {
            if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text.Trim()))
            {
                string reportString =
                    CmdletSignature(cmdlet) +
                    text;

                // 20140317
                // turning off the logger
                // Logger.Info(reportString);
            }
            else
            {
                // 20140317
                // turning off the logger
                // Logger.Info(text);
            }
        }
Пример #11
0
 public virtual void LogCmdlet(CommonCmdletBase cmdlet)
 {
     Info(GetObjectPropertiesInfo(cmdlet));
 }
Пример #12
0
 internal UIAAddWizardStepCommand(CommonCmdletBase cmdlet)
     : base(cmdlet)
 {
 }
Пример #13
0
 public NewWizardCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
Пример #14
0
        protected internal void WriteWarn(CommonCmdletBase cmdlet, string text)
        {
            string reportString =
                CmdletSignature(cmdlet) +
                text;

            TMX.Logger.Warn(reportString);
        }
Пример #15
0
 internal UIACommand(CommonCmdletBase cmdlet)
 {
     this.Cmdlet = cmdlet;
 }
        private void getConditions(string name, string automationId, string className, string controlType)
        {
            this.ResultCondition = null;

            GetControlCmdletBase cmdlet =
                new GetControlCmdletBase();
            cmdlet.Name = name;
            cmdlet.AutomationId = automationId;
            cmdlet.Class = className;

            UIAutomation.CommonCmdletBase common =
                new UIAutomation.CommonCmdletBase();

            this.ResultCondition =
                (common.getControlConditions(cmdlet, controlType, cmdlet.CaseSensitive, true) as AndCondition);
        }
Пример #17
0
 protected internal void WriteDebug(CommonCmdletBase cmdlet, object obj)
 {
     string reportString =
         CmdletSignature(cmdlet) +
         obj.ToString();
     WriteLog(reportString);
 }
 public NewRemoteDesktopProtocolFileCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
Пример #19
0
 internal virtual string GetPropertyString(CommonCmdletBase cmdlet, PropertyInfo propertyInfo)
 {
     string result = string.Empty;
     
     if (null == propertyInfo) return result;
     
     object tempResult = string.Empty;
     try {
         tempResult = propertyInfo.GetValue(cmdlet, null) ?? string.Empty;
     } catch (Exception) {
         
         return string.Empty;
     }
     
     if (string.IsNullOrEmpty(tempResult.ToString())) return result;
     
     result += " -";
     result += propertyInfo.Name;
     result += " ";
     
     string tempString = string.Empty;
     
     switch (tempResult.GetType().Name) {
         case "String":
             result += "\"";
             result += tempResult;
             result += "\"";
             return result;
         case "String[]":
             tempString = string.Empty;
             foreach (string singleElement in tempResult as IEnumerable) {
                 tempString += ",";
                 tempString += singleElement;
             }
             if (0 < tempString.Length) tempString = tempString.Substring(1);
             result += tempString;
             return result;
         case "IUiElement":
             var convertCmdlet =
                 new ConvertToUiaSearchCriteriaCommand {
                 Full = true
             };
             // result += "\r\n\t";
             result += convertCmdlet.ConvertElementToSearchCriteria((IUiElement)tempResult);
             // result += "\r\n\t";
             return result;
         case "IUiElement[]":
             var convertCmdlet2 =
                 new ConvertToUiaSearchCriteriaCommand {
                 Full = true
             };
             foreach (IUiElement element in tempResult as IUiElement[]) {
                 // result += "\r\n\t";
                 result += convertCmdlet2.ConvertElementToSearchCriteria(element);
                 // result += "\r\n\t";
             }
             return result;
         case "Int32":
             result += tempResult.ToString();
             return result;
         case "SwitchParameter":
             bool tempBool = (SwitchParameter)tempResult;
             result += tempBool ? "$true" : "$false";
             return result;
         case "Hashtable":
             result += ConvertHashtableToString((Hashtable)tempResult);
             return result;
         case "Hashtable[]":
             tempString = string.Empty;
             foreach (Hashtable hashtable in (tempResult as Hashtable[])) {
                 tempString += ",";
                 tempString += ConvertHashtableToString(hashtable);
             }
             if (0 < tempString.Length) tempString = tempString.Substring(1);
             result += tempString;
             return result;
         default:
             result += tempResult.ToString();
             return result;
     }
 }
Пример #20
0
        protected internal void WriteDebug(CommonCmdletBase cmdlet, string text)
        {
            string reportString =
                CmdletSignature(cmdlet) +
                text;

            // 20130501
            //WriteLog(reportString);
            this.WriteLog(LogLevels.Debug, reportString);
        }
Пример #21
0
 public virtual void LogCmdlet(CommonCmdletBase cmdlet)
 {
     Info(GetObjectPropertiesInfo(cmdlet));
 }
Пример #22
0
        protected internal void WriteDebug(CommonCmdletBase cmdlet, object obj)
        {
            string reportString =
                CmdletSignature(cmdlet) +
                obj.ToString();

            // 20130501
            //WriteLog(reportString);
            this.WriteLog(LogLevels.Debug, reportString);
        }
Пример #23
0
        internal virtual string GetPropertyString(CommonCmdletBase cmdlet, PropertyInfo propertyInfo)
        {
            string result = string.Empty;

            if (null == propertyInfo)
            {
                return(result);
            }

            object tempResult = string.Empty;

            try {
                tempResult = propertyInfo.GetValue(cmdlet, null) ?? string.Empty;
            } catch (Exception) {
                return(string.Empty);
            }

            if (string.IsNullOrEmpty(tempResult.ToString()))
            {
                return(result);
            }

            result += " -";
            result += propertyInfo.Name;
            result += " ";

            string tempString = string.Empty;

            switch (tempResult.GetType().Name)
            {
            case "String":
                result += "\"";
                result += tempResult;
                result += "\"";
                return(result);

            case "String[]":
                tempString = string.Empty;
                foreach (string singleElement in tempResult as IEnumerable)
                {
                    tempString += ",";
                    tempString += singleElement;
                }
                if (0 < tempString.Length)
                {
                    tempString = tempString.Substring(1);
                }
                result += tempString;
                return(result);

            case "IUiElement":
                var convertCmdlet =
                    new ConvertToUiaSearchCriteriaCommand {
                    Full = true
                };
                // result += "\r\n\t";
                result += convertCmdlet.ConvertElementToSearchCriteria((IUiElement)tempResult);
                // result += "\r\n\t";
                return(result);

            case "IUiElement[]":
                var convertCmdlet2 =
                    new ConvertToUiaSearchCriteriaCommand {
                    Full = true
                };
                foreach (IUiElement element in tempResult as IUiElement[])
                {
                    // result += "\r\n\t";
                    result += convertCmdlet2.ConvertElementToSearchCriteria(element);
                    // result += "\r\n\t";
                }
                return(result);

            case "Int32":
                result += tempResult.ToString();
                return(result);

            case "SwitchParameter":
                bool tempBool = (SwitchParameter)tempResult;
                result += tempBool ? "$true" : "$false";
                return(result);

            case "Hashtable":
                result += ConvertHashtableToString((Hashtable)tempResult);
                return(result);

            case "Hashtable[]":
                tempString = string.Empty;
                foreach (Hashtable hashtable in (tempResult as Hashtable[]))
                {
                    tempString += ",";
                    tempString += ConvertHashtableToString(hashtable);
                }
                if (0 < tempString.Length)
                {
                    tempString = tempString.Substring(1);
                }
                result += tempString;
                return(result);

            default:
                result += tempResult.ToString();
                return(result);
            }
        }
Пример #24
0
 public RemoveWizardStepCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
 internal UIANewRemoteDesktopProtocolFileCommand(CommonCmdletBase cmdlet)
     : base(cmdlet)
 {
 }
Пример #26
0
 public ExitWizardCommand(CommonCmdletBase cmdlet) : base(cmdlet)
 {
 }
Пример #27
0
 public AddWizardStepCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
Пример #28
0
 public StepWizardCommand(CommonCmdletBase cmdlet) : base(cmdlet)
 {
 }
Пример #29
0
 // 20140211
 // internal UiaCommand(CommonCmdletBase cmdlet)
 public UiaCommand(CommonCmdletBase cmdlet)
 {
     Cmdlet = cmdlet;
 }
Пример #30
0
 protected internal void WriteDebug(CommonCmdletBase cmdlet, string text)
 {
     string reportString =
         CmdletSignature(cmdlet) +
         text;
     WriteLog(reportString);
 }
Пример #31
0
 public ExitWizardCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
Пример #32
0
 internal UIAInvokeWizardCommand(CommonCmdletBase cmdlet)
     : base(cmdlet)
 {
 }
Пример #33
0
 public AddWizardStepCommand(CommonCmdletBase cmdlet) : base(cmdlet)
 {
 }
Пример #34
0
 public NewRemoteDesktopProtocolFileCommand(CommonCmdletBase cmdlet) : base(cmdlet)
 {
 }
Пример #35
0
 public NewWizardCommand(CommonCmdletBase cmdlet) : base(cmdlet)
 {
 }
Пример #36
0
 internal UIANewWizardCommand(CommonCmdletBase cmdlet)
     : base(cmdlet)
 {
 }
 private void checkConditionsArray(
     string controlType,
     string controlTypeProperty,
     string controlTypeValue)
 {
     Condition[] conditions = null;
     cmdlet =
         new UIAutomation.Commands.GetUIAControlCommand();
     cmdletBase =
         // 20130221
         // new UIAutomation.CommonCmdletBase();
         new UIAutomation.GetControlCmdletBase();
     AndCondition condition =
         // 20130127
         //cmdlet.getControlConditions(cmdlet, controlType);
         // 20130128
         //cmdlet.getControlConditions(cmdlet, controlType, ((GetControlCmdletBase)cmdlet).CaseSensitive);
         //cmdlet.getControlConditions(cmdlet, controlType, ((GetControlCmdletBase)cmdlet).CaseSensitive, true);
         cmdlet.getControlConditions(cmdlet, controlType, ((GetControlCmdletBase)cmdlet).CaseSensitive, true) as AndCondition;
     conditions = condition.GetConditions();
     foreach (Condition cond in conditions) {
         if ((cond as PropertyCondition) != null) {
             Assert.AreEqual(
                 controlTypeProperty,
                 (cond as PropertyCondition).Property.ProgrammaticName);
             Assert.AreEqual(
                 controlTypeValue,
                 (cond as PropertyCondition).Value.ToString());
         } else {
             Assert.AreEqual(cond, Condition.TrueCondition);
         }
     }
 }
Пример #38
0
 public StepWizardCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
Пример #39
0
 public RemoveWizardStepCommand(CommonCmdletBase cmdlet) : base(cmdlet)
 {
 }