SetValue() public method

public SetValue ( string value ) : void
value string
return void
示例#1
0
        // -------------------------------------------------------------------
        // Call ValuePattern.SetValue("123456789") on control whose limit is set to 1 character
        // -------------------------------------------------------------------
        private void TS_SetValueOversize(ValuePattern valuePattern, CheckType checkType)
        {
            bool isReadOnly = valuePattern.Current.IsReadOnly;
            bool isPassword = m_le.Current.IsPassword;
            string value = "123456789";
            IntPtr _hwnd = Helpers.CastNativeWindowHandleToIntPtr(m_le);
            NativeMethods.HWND hwnd = NativeMethods.HWND.Cast(_hwnd);
            IntPtr wParam = new IntPtr(1);
            IntPtr result;

            int    lastWin32Error    = Marshal.GetLastWin32Error();
            int    resultInt;

            IntPtr resultSendMessage = UnsafeNativeMethods.SendMessageTimeout(hwnd, NativeMethods.EM_LIMITTEXT, wParam, IntPtr.Zero, 1, 10000, out result);
            if (resultSendMessage == IntPtr.Zero)
            {
                throw new InvalidOperationException("SendMessageTimeout() timed out");
            }
            resultInt = unchecked((int)(long)result);

            try
            {
                valuePattern.SetValue(value);
            }
            catch (InvalidOperationException)
            {
                Comment("As expected, unable to set value of control limited to 1 character with a string \"123456789\"");
            }
            catch (UnauthorizedAccessException actualException)
            {
                if (isPassword == true)
                {
                    Comment("As expected, unable to set value of password control (UnauthorizedAccessException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_SetValue", checkType);
            }

            Comment("Successfully called ValuePattern.SetValue(\"A\"), must be control that is not numeric-only");
            m_TestStep++;
        }
示例#2
0
        // -------------------------------------------------------------------
        // Call ValuePattern.SetValue()
        // -------------------------------------------------------------------
        private void TS_SetValue(ValuePattern valuePattern, CheckType checkType)
        {
            bool isReadOnly = valuePattern.Current.IsReadOnly;
            bool isPassword = m_le.Current.IsPassword;
            string value = "1";
            IntPtr hwnd = Helpers.CastNativeWindowHandleToIntPtr(m_le);

            try
            {
                valuePattern.SetValue(value);
            }
            catch (ElementNotEnabledException actualException)
            {
                if (SafeNativeMethods.IsWindowEnabled(hwnd) == false)
                    Comment("As expected, unable to set value of disabled control");
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (InvalidOperationException actualException)
            {
                if (isReadOnly == true)
                {
                    Comment("As expected, unable to set value of read-only control (InvalidOperationException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (UnauthorizedAccessException actualException)
            {
                if (isPassword == true)
                {
                    Comment("As expected, unable to set value of password control (UnauthorizedAccessException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_SetValue", checkType);
            }

            Comment("Successfully called ValuePattern.SetValue(" + value + ")");
            m_TestStep++;
        }
示例#3
0
        // -------------------------------------------------------------------
        // Call ValuePattern.SetValue(Non-numeric value) raising ArgumentException for numeric-only fields
        // -------------------------------------------------------------------
        private void TS_SetValueAlpha(ValuePattern valuePattern, CheckType checkType)
        {
            bool isReadOnly = valuePattern.Current.IsReadOnly;
            bool isPassword = m_le.Current.IsPassword;
            string value = "A";
            IntPtr hwnd = Helpers.CastNativeWindowHandleToIntPtr(m_le);

            try
            {
                valuePattern.SetValue(value);
            }
            catch (ArgumentException)
            {
                Comment("As expected, unable to set value of numeric only control with an alpha numeric string ('A')");
                m_TestStep++;
                return;
            }
            catch (InvalidOperationException actualException)
            {
                if (isReadOnly == true)
                {
                    Comment("As expected, unable to set value of read-only control (InvalidOperationException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (UnauthorizedAccessException actualException)
            {
                if (isPassword == true)
                {
                    Comment("As expected, unable to set value of password control (UnauthorizedAccessException)");
                    m_TestStep++;
                    return;
                }
                else
                    TestException(null, actualException, "TS_SetValue", checkType);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(null, actualException, "TS_SetValue", checkType);
            }

            Comment("Successfully called ValuePattern.SetValue(\"A\"), must be control that is not numeric-only");
            m_TestStep++;
        }
示例#4
0
 private CustomCommandResponse Execute(ValuePattern valuePattern, string assemblyFile, string typeName, MethodInfo method, object[] arguments)
 {
     var commandSerializer = new CustomCommandSerializer();
     string serializedCommand = commandSerializer.Serialize(new FileInfo(assemblyFile).Name, typeName, method.Name, arguments);
     valuePattern.SetValue(serializedCommand);
     ActionPerformed(Action.WindowMessage);
     string value = valuePattern.Current.Value;
     return new CustomCommandResponse(commandSerializer.ToObject(value));
 }