コード例 #1
0
        /// <summary>
        /// Generates the default value test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateDefaultValueTestCase(xControl control)
        {
            if (!string.IsNullOrEmpty(control.Value) || control.PrimaryKey)
            {
                return(null);
            }

            int minValue, maxValue;

            if (!int.TryParse(control.MinValue, out minValue))
            {
                minValue = 1;
            }
            if (!int.TryParse(control.MaxValue, out maxValue))
            {
                maxValue = 9999;
            }

            var testValue = RandomValueHelper.GenerateRandomInteger(minValue, maxValue);

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_Default",
                Type = TestCaseType.DEFAULT,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", {1});", control.Name, testValue),
                TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", {1});", control.Name, testValue),
                TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                Description = string.Empty,
                WillSaveSucceed = true
            });
        }
コード例 #2
0
        /// <summary>
        /// Builds the attributes for control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <param name="node">The node.</param>
        private void BuildAttributesForControl(xControl control, TreeNode node)
        {
            var attributes = control.GetType().GetFields()
                             .Where(a =>
            {
                if (a.IsDefined(typeof(FormDesignerAttributeAttribute), true))
                {
                    var formDesignerAttribute = a.GetCustomAttributes(typeof(FormDesignerAttributeAttribute), true) as FormDesignerAttributeAttribute[];
                    if (formDesignerAttribute.Length > 0 &&
                        formDesignerAttribute[0].HideAttribute == false &&
                        //(formDesignerAttribute[0].ReleventControls.Contains(control.Type) || formDesignerAttribute[0].ReleventControls.Contains(ControlType.All)) &&
                        formDesignerAttribute[0].AttributeType == AttributeType.Common
                        )
                    {
                        return(true);
                    }
                }

                return(false);
            });

            node.Nodes.AddRange(attributes.Select(x => { return(new TreeNode(x.Name)
                {
                    Name = x.Name
                }); }).OrderBy(a => a.Text).ToArray());
        }
コード例 #3
0
        /// <summary>
        /// Verifies the specified control.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        public IEnumerable <string> Verify(xControl control)
        {
            var verificationResults = new List <string>();
            var dbColumnLength      = DbTypeParser.GetColumnLength(control.DBType);
            var maxLength           = control.MaxLength;

            if (dbColumnLength < maxLength)
            {
                verificationResults.Add(string.Format("{0}: Database column length is lesser than the value specified in MaxLength attribute. {1}",
                                                      control.Caption, Environment.NewLine));
            }

            return(verificationResults);
        }
コード例 #4
0
        public IEnumerable <string> Verify(xControl control)
        {
            var verificationResults = new List <string>();

            if (!string.IsNullOrEmpty(control.DataSource))
            {
                var dataSourceItems = control.DataSource.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                if (dataSourceItems.Length < 3)
                {
                    verificationResults.Add(string.Format("{0}: DataSource is not formatted correctly. Possible failure. {1}",
                                                          control.Caption, Environment.NewLine));
                }
            }
            return(verificationResults);
        }
コード例 #5
0
        /// <summary>
        /// Generates the less than maximum length test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateLessThanMaxLengthTestCase(xControl control)
        {
            var testValue = RandomValueHelper.GenerateRandomString(control.MaxLength - 1);

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_MaxLength_Negative",
                Type = TestCaseType.POSITIVE,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                WillSaveSucceed = true,
                Description = string.Format("TestCase for testing MaxLength of TextBox ({0}). Value is less than MaxLength.", control.Caption)
            });
        }
コード例 #6
0
        /// <summary>
        /// Generates the greater than maximum length test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateGreaterThanMaxLengthTestCase(xControl control)
        {
            var testValue = RandomValueHelper.GenerateRandomString(control.MaxLength + 1);

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_MaxLength_Negative",
                Type = TestCaseType.NEGATIVE,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                //TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", \"{1}\");", control.Name, testValue.Substring(0, testValue.Length - 1)),
                //TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue.Substring(0, testValue.Length - 1)),
                //TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue.Substring(0, testValue.Length - 1)),
                OnScreenValidator = "AssertIfToasterExist();",
                WillSaveSucceed = false,
                Description = string.Format("TestCase for testing MaxLength of TextBox({0}). Value is greater than MaxLength.", control.Caption),
            });
        }
コード例 #7
0
        /// <summary>
        /// Generates the less than minimum value test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateLessThanMinValueTestCase(xControl control)
        {
            int minValue;
            int testValue = int.MinValue;

            if (int.TryParse(control.MinValue, out minValue))
            {
                testValue = minValue - 1;
            }

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_MinValue_Negative",
                Type = TestCaseType.NEGATIVE,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", {1});", control.Name, testValue),
                OnScreenValidator = string.Format("AssertControlSpanErrorMessage(\"{0}\");", control.Name),
                Description = string.Format("TestCase for MinValue of Integer control ({0}). Value is less than the MinValue specified.", control.Caption),
                WillSaveSucceed = false
            });
        }
コード例 #8
0
 /// <summary>
 /// Generates the negative security test case.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <returns></returns>
 private TestCaseComponent GenerateNegativeSecurityTestCase(xControl control)
 {
     if (control.ReadOnly)
     {
         var testValue = RandomValueHelper.GenerateRandomString(control.MaxLength - 1);
         return(new TestCaseComponent
         {
             Name = $"{control.Name}_DataTamper_Security",
             Type = TestCaseType.NEGATIVE,
             TestCaseSetter = string.Format("SetTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
             //TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", \"{1}\");", control.Name, testValue),
             TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
             //TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
             OnScreenValidator = "AssertIfToasterExist();",
             WillSaveSucceed = false,
             Description = string.Format("TestCase for testing data tampering in form TextBox ({0}). Server side validation implemented!", control.Caption)
         });
     }
     return(null);
 }
コード例 #9
0
        /// <summary>
        /// Validates the control.
        /// </summary>
        /// <param name="control">The control.</param>
        private void ValidateControl(xControl control)
        {
            if (!Configurator.Container.IsRegistered <IControlVerifier>(control.Type.ToString()))
            {
                return;
            }

            var verifier = Configurator.Container.Resolve <IControlVerifier>(control.Type.ToString());

            if (verifier == null)
            {
                return;
            }

            var result = verifier.Verify(control);

            if (result != null && result.Count() > 0)
            {
                txtWarnings.AppendText(string.Join(Environment.NewLine, result));
            }
        }
コード例 #10
0
        /// <summary>
        /// Generates the greater than minimum value test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateGreaterThanMinValueTestCase(xControl control)
        {
            int minValue;
            int testValue = int.MinValue;

            if (int.TryParse(control.MinValue, out minValue))
            {
                testValue = minValue + 1;
            }

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_MinValue_Positive",
                Type = TestCaseType.POSITIVE,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", {1});", control.Name, testValue),
                TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", {1});", control.Name, testValue),
                TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                Description = string.Format("TestCase for MinValue of Integer control ({0}). Value is greater than the MinValue specified.", control.Caption),
                WillSaveSucceed = true
            });
        }
コード例 #11
0
        /// <summary>
        /// Generates the greater than maximum value test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateGreaterThanMaxValueTestCase(xControl control)
        {
            decimal maxValue;
            decimal testValue = decimal.MaxValue;

            if (decimal.TryParse(control.MaxValue, out maxValue))
            {
                testValue = maxValue + 1;
            }

            testValue = Math.Round(testValue, 2);

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_MaxValue_Negative",
                Type = TestCaseType.NEGATIVE,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", {1});", control.Name, testValue),
                OnScreenValidator = string.Format("AssertControlSpanErrorMessage(\"{0}\");", control.Name),
                Description = string.Format("TestCase for MaxValue of Numeric control ({0}). Value is greater than the MaxValue specified.", control.Caption),
                WillSaveSucceed = false
            });
        }
コード例 #12
0
        /// <summary>
        /// Generates the default value test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateDefaultValueTestCase(xControl control)
        {
            if (!string.IsNullOrEmpty(control.Value) || control.PrimaryKey)
            {
                return(null);
            }

            var length    = Math.Min(DbTypeParser.GetColumnLength(control.DBType), control.MaxLength);
            var testValue = RandomValueHelper.GenerateRandomString(length);

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_Default",
                Type = TestCaseType.DEFAULT,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                Description = string.Empty,
                WillSaveSucceed = true
            });
        }
コード例 #13
0
        /// <summary>
        /// Generates the equal to minimum value test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateEqualToMinValueTestCase(xControl control)
        {
            decimal minValue;
            decimal testValue = decimal.MinValue;

            if (decimal.TryParse(control.MinValue, out minValue))
            {
                testValue = minValue;
            }

            testValue = Math.Round(testValue, 2);

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_MaxValue_Negative",
                Type = TestCaseType.POSITIVE,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", {1});", control.Name, testValue),
                TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", {1}m);", control.Name, testValue),
                TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                Description = string.Format("TestCase for MinValue of Numeric control ({0}). Value is equal to the MinValue specified.", control.Caption),
                WillSaveSucceed = true
            });
        }
コード例 #14
0
        /// <summary>
        /// Generates the greater than minimum value test case.
        /// </summary>
        /// <param name="control">The control.</param>
        /// <returns></returns>
        private TestCaseComponent GenerateGreaterThanMinValueTestCase(xControl control)
        {
            decimal minValue, maxValue;
            decimal testValue = decimal.MinValue;

            if (!decimal.TryParse(control.MaxValue, out maxValue))
            {
                maxValue = 9999.99m;
            }

            if (decimal.TryParse(control.MinValue, out minValue))
            {
                if (maxValue >= (minValue + 1))
                {
                    testValue = minValue + 1;
                }
                else
                {
                    testValue = minValue + (maxValue - minValue) / 2;
                }
            }

            testValue = Math.Round(testValue, 2);

            return(new TestCaseComponent
            {
                Name = $"{control.Name}_MaxValue_Positive",
                Type = TestCaseType.POSITIVE,
                TestCaseSetter = string.Format("SetTextbox(\"{0}\", {1});", control.Name, testValue),
                TestCaseDBValidator = string.Format("Assert_Data(\"{0}\", {1}m);", control.Name, testValue),
                TestCaseEditModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                TestCaseViewModeValidator = string.Format("AssertTextbox(\"{0}\", \"{1}\");", control.Name, testValue),
                Description = string.Format("TestCase for MinValue of Numeric control ({0}). Value is greater than the MinValue specified.", control.Caption),
                WillSaveSucceed = true
            });
        }
コード例 #15
0
 /// <summary>
 /// Generates the default value test case.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <returns></returns>
 private TestCaseComponent GeneratePositiveSecurityTestCase(xControl control)
 {
     return(null);
 }