The CommonCmdletBase class in the top of cmdlet hierarchy.
Inheritance: PSTestLib.PSCmdletBase
コード例 #1
0
        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
ファイル: LogHelper.cs プロジェクト: MatkoHanus/STUPS
 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);
        }
コード例 #7
0
        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;
        }
コード例 #8
0
 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
ファイル: NewWizardCommand.cs プロジェクト: MatkoHanus/STUPS
 public NewWizardCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
コード例 #14
0
ファイル: CommonCmdletBase.cs プロジェクト: krukovskiy/STUPS
        protected internal void WriteWarn(CommonCmdletBase cmdlet, string text)
        {
            string reportString =
                CmdletSignature(cmdlet) +
                text;

            TMX.Logger.Warn(reportString);
        }
コード例 #15
0
ファイル: UIACommand.cs プロジェクト: krisdages/STUPS
 internal UIACommand(CommonCmdletBase cmdlet)
 {
     this.Cmdlet = cmdlet;
 }
コード例 #16
0
        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
ファイル: CommonCmdletBase.cs プロジェクト: uiatester/STUPS
 protected internal void WriteDebug(CommonCmdletBase cmdlet, object obj)
 {
     string reportString =
         CmdletSignature(cmdlet) +
         obj.ToString();
     WriteLog(reportString);
 }
コード例 #18
0
 public NewRemoteDesktopProtocolFileCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
コード例 #19
0
ファイル: LogHelper.cs プロジェクト: MatkoHanus/STUPS
 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
ファイル: CommonCmdletBase.cs プロジェクト: krukovskiy/STUPS
        protected internal void WriteDebug(CommonCmdletBase cmdlet, string text)
        {
            string reportString =
                CmdletSignature(cmdlet) +
                text;

            // 20130501
            //WriteLog(reportString);
            this.WriteLog(LogLevels.Debug, reportString);
        }
コード例 #21
0
ファイル: LogHelper.cs プロジェクト: MatkoHanus/STUPS
 public virtual void LogCmdlet(CommonCmdletBase cmdlet)
 {
     Info(GetObjectPropertiesInfo(cmdlet));
 }
コード例 #22
0
ファイル: CommonCmdletBase.cs プロジェクト: krukovskiy/STUPS
        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)
 {
 }
コード例 #25
0
 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
ファイル: UIACommand.cs プロジェクト: MatkoHanus/STUPS
 // 20140211
 // internal UiaCommand(CommonCmdletBase cmdlet)
 public UiaCommand(CommonCmdletBase cmdlet)
 {
     Cmdlet = cmdlet;
 }
コード例 #30
0
ファイル: CommonCmdletBase.cs プロジェクト: uiatester/STUPS
 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)
 {
 }
コード例 #37
0
 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
ファイル: StepWizardCommand.cs プロジェクト: MatkoHanus/STUPS
 public StepWizardCommand(CommonCmdletBase cmdlet) : base (cmdlet)
 {
 }
コード例 #39
0
 public RemoveWizardStepCommand(CommonCmdletBase cmdlet) : base(cmdlet)
 {
 }