Exemplo n.º 1
0
        /// <summary>
        /// Gets a list of declarations emitted by the control.
        /// </summary>
        public void AddDeclarations(HelperDefinition helper, SeleniumGeneratorContext context)
        {
            // determine the name
            var uniqueName = DetermineName(context);

            // make the name unique
            if (context.UsedNames.Contains(uniqueName))
            {
                var index = 1;
                while (context.UsedNames.Contains(uniqueName + index))
                {
                    index++;
                }
                uniqueName = uniqueName + index;
            }
            context.UsedNames.Add(uniqueName);
            context.UniqueName = uniqueName;

            // determine the selector
            var selector = TryGetNameFromProperty(context.Control, UITests.NameProperty);

            if (selector == null)
            {
                selector = uniqueName;

                AddUITestNameProperty(helper, context, uniqueName);
            }
            context.Selector = selector;

            AddDeclarationsCore(helper, context);
        }
Exemplo n.º 2
0
        private void AddUITestNameProperty(HelperDefinition helper, SeleniumGeneratorContext context, string uniqueName)
        {
            // find end of the tag
            var token = context.Control.DothtmlNode.Tokens.First(t => t.Type == DothtmlTokenType.CloseTag || t.Type == DothtmlTokenType.Slash);

            helper.MarkupFileModifications.Add(new MarkupFileInsertText()
            {
                Text     = " UITests.Name=\"" + uniqueName + "\"",
                Position = token.StartPosition
            });
        }
Exemplo n.º 3
0
 public virtual bool CanAddDeclarations(HelperDefinition helperDefinition, SeleniumGeneratorContext context)
 {
     return(true);
 }
Exemplo n.º 4
0
 protected abstract void AddDeclarationsCore(HelperDefinition helper, SeleniumGeneratorContext context);