Ejemplo n.º 1
0
        public void UmaButtonLinkExceptionTest()
        {
            string rndLabel = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(rndLabel);

            Action action = () => this.htmlHelper.UmaButtonLink(rndLabel, null, faIcn, null);
            action.ShouldThrow<ArgumentNullException>();
        }
        public void FontAwesomeCtorAndPropSizeTest()
        {
            string randomStr = RandomData.GetString(4, false);
            FontAwesomeIcon fontA = new FontAwesomeIcon(randomStr);

            fontA.IconName.Should().BeEquivalentTo(randomStr);
            fontA.Size.Should().Be(IconSize.Normal);
        }
Ejemplo n.º 3
0
        public void UmaButtonGeneralExceptionTest()
        {
            string rndLabel = RandomData.GetStringWord();
            FontAwesomeIcon fnIcn = new FontAwesomeIcon(rndLabel);

            Action action = () => this.htmlHelper.UmaButton(null, rndLabel, UmaButtonType.Default, fnIcn, null);
            action.ShouldThrow<ArgumentNullException>();
        }
        public void FontAwesomeCtorAndPropJustificationTest()
        {
            string randomStr = RandomData.GetString(4, false);
            FontAwesomeIcon fontA = new FontAwesomeIcon(randomStr);

            fontA.IconName.Should().BeEquivalentTo(randomStr);
            fontA.Justification.Should().Be(IconJustification.Left);
        }
Ejemplo n.º 5
0
        public void UmaButtonLinkGeneralWithFontAwesomeJustificationRightTest()
        {
            string rndLabel = RandomData.GetStringWord();
            string rndUrl = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(RandomData.GetStringWord()) { Justification = IconJustification.Right };

            var result = this.htmlHelper.UmaButtonLink(rndLabel, rndUrl, faIcn, null).ToString();

            //result example
            //<a class="btn btn-info" href="íāzzšеī">ázöвęкоc <i class="fa ázöвęкоc"></i></a>
            result.Should().EndWith(String.Format(@"{0} <i class=""fa {1}""></i></a>", rndLabel, faIcn.IconName));
        }
Ejemplo n.º 6
0
        public static MvcHtmlString UmaButton(this HtmlHelper htmlHelper, string id, string label, UmaButtonType buttonType, FontAwesomeIcon fontAwesomeIcon, object htmlAttributes)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(id);
            }

            if (htmlHelper == null)
            {
                throw new ArgumentNullException("htmlHelper");
            }

            TagBuilder button = new TagBuilder("button");

            button.GenerateId(id);
            button.Attributes.Add("name", id);

            string localizedLabel = label;
            // TO DO: Andrejs
            // GetTranslation(label, htmlHelper.ViewBag.FeatureName);

            if (fontAwesomeIcon != null && fontAwesomeIcon.Justification == IconJustification.Right)
            {
                button.InnerHtml = string.Concat(localizedLabel, " ", fontAwesomeIcon.Html);
            }
            else
            {
                button.InnerHtml = string.Concat(fontAwesomeIcon == null ? string.Empty : fontAwesomeIcon.Html + " ", localizedLabel);
            }

            button.AddCssClass(GetButtonCssClass(buttonType));
            button.AddCssClass("btn");
            button.Attributes.Add("type",
                buttonType == UmaButtonType.FormSubmit ? "submit" : "button");
            AddAdditionalAttributes(htmlAttributes, button);
            return MvcHtmlString.Create(button.ToString(TagRenderMode.Normal));
        }
Ejemplo n.º 7
0
        public void UmaButtonLinktWithAdditionalClassAttribute()
        {
            string rndLabel = RandomData.GetStringWord();
            string rndValue = RandomData.GetStringWord();
            string rndUrl = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(rndLabel);

            var result = this.htmlHelper.UmaButtonLink(rndLabel, rndUrl, faIcn, new { @class = rndValue }).ToString();

            //result example
            //<a RandomKey="èöhzfsìúпgģи" class="ūáfwsdkg btn btn-info" href="iйоаxūļцfx"><i class="fa èöhzfsìúпgģи"></i> èöhzfsìúпgģи</a>
            result.Should().Contain("class=\"" + rndValue + " btn btn-info");
        }
Ejemplo n.º 8
0
        public void UmaButtonWithHtmlNullAttributesTest()
        {
            string rndId = RandomData.GetStringNumber(5);
            string rndLabel = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(rndLabel) { Size = IconSize.TrippleSize };

            //act
            //This test checks that no erros should be thrown in case htmlAttributes object is null
            var result = this.htmlHelper.UmaButton(rndId, rndLabel, UmaButtonType.Default, faIcn, null).ToString();

            //example of result
            //<button class="btn btn-default" name="72551" type="button"><i class="fa ņрмīkę fa-3x"></i> вéxeįfрuèsāнz</button>
            result.Should().Contain("<i class=\"fa " + faIcn.IconName + " fa-3x\">");
        }
Ejemplo n.º 9
0
        public void UmaButtonWithHtmlAttributesKeyRandomTest()
        {
            string rndId = RandomData.GetStringNumber(5);
            string rndLabel = RandomData.GetStringWord();
            string rndValue = RandomData.GetStringWord();
            string rndKey = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(rndLabel);

            var result = this.htmlHelper.UmaButton(rndId, rndLabel, UmaButtonType.Default, faIcn, new { Key = rndKey, Value = rndValue }).ToString();

            //result example
            //<button Key="gyšļēоеįģáр" Value="енubu" class="btn btn-default" name="85965" type="button"><i class="fa ļnоžíūāģb"></i> ļnоžíūāģb</button>
            result.Should().Contain("<button Key=\"" + rndKey + "\" Value=\"" + rndValue);
        }
Ejemplo n.º 10
0
        public void UmaButtonWithHtmlAttributesKeyClassTest()
        {
            string rndId = RandomData.GetStringNumber(5);
            string rndLabel = RandomData.GetStringWord();
            string rndValue = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(rndLabel);

            var result = this.htmlHelper.UmaButton(rndId, rndLabel, UmaButtonType.Default, faIcn, new { @class = rndValue }).ToString();

            //result example
            //<button RandomKey="ìņuācl" class="íkìrjsнāēм btn btn-default" name="62961" type="button"><i class="fa ìņuācl"></i> ìņuācl</button>
            result.Should().Contain("class=\"" + rndValue + " btn btn-default");
        }
Ejemplo n.º 11
0
        public void UmaButtonWithFontAwesomeIconSizeTwiceSizeTest()
        {
            string rndId = RandomData.GetStringNumber(5);
            string rndLabel = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(rndLabel) { Size = IconSize.TwiceSize };

            var result = this.htmlHelper.UmaButton(rndId, rndLabel, UmaButtonType.Default, faIcn, null).ToString();

            //example of result
            //<button class="btn btn-default" name="72551" type="button"><i class="fa ņрмīkę fa-2x"></i> вéxeįfрuèsāнz</button>
            result.Should().Contain("<i class=\"fa " + faIcn.IconName + " fa-2x\">");
        }
Ejemplo n.º 12
0
        public void UmaButtonWithFontAwesomeIconIconJustificationRightTest()
        {
            string rndId = RandomData.GetStringNumber(5);
            string rndLabel = RandomData.GetStringWord();
            FontAwesomeIcon faIcn = new FontAwesomeIcon(rndLabel) { Size = IconSize.Larger, Justification = IconJustification.Right };

            var result = this.htmlHelper.UmaButton(rndId, rndLabel, UmaButtonType.Default, faIcn, null).ToString();

            //example of result
            //<button class="btn btn-default" name="72471" type="button">уjēoķmq <i class="fa уjēoķmq fa-lg"></i></button>
            result.Should().Contain(" <i class=\"fa " + faIcn.IconName + " fa-lg\">");
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates the HTML markup for button in UI with necessary specified styling classes and icon
 /// </summary>
 /// <param name="htmlHelper">The HTML helper.</param>
 /// <param name="id">The identifier of a button. Also becomes a name</param>
 /// <param name="label">The label to display on button. It is automatically localized in current UI Culture</param>
 /// <param name="buttonType">Semantic type of the button.</param>
 /// <param name="fontAwesomeIconName">Specify font awesome icon full name (like "fa-check-square-o"). Refer to http://fontawesome.io/icons/ for names.</param>
 public static MvcHtmlString UmaButton(this HtmlHelper htmlHelper, string id, string label, UmaButtonType buttonType, string fontAwesomeIconName)
 {
     FontAwesomeIcon iconDef = new FontAwesomeIcon(fontAwesomeIconName) { Size = IconSize.Larger };
     return UmaButton(htmlHelper, id, label, buttonType, iconDef, null);
 }
Ejemplo n.º 14
0
        public static MvcHtmlString UmaButtonLink(this HtmlHelper htmlHelper, string label, string redirectUri, FontAwesomeIcon fontAwesomeIcon, object htmlAttributes, UmaButtonType type = UmaButtonType.ViewOperation)
        {
            if (string.IsNullOrEmpty(redirectUri))
            {
                throw new ArgumentNullException("redirectUri");
            }

            if (htmlHelper == null)
            {
                throw new ArgumentNullException("htmlHelper");
            }

            TagBuilder link = new TagBuilder("a");
            link.Attributes.Add("href", redirectUri);
            // TODO :  Andrejs
            string localizedLabel = label;
            // GetTranslation(label, htmlHelper.ViewBag.FeatureName);

            if (fontAwesomeIcon != null && fontAwesomeIcon.Justification == IconJustification.Right)
            {
                link.InnerHtml = string.Concat(localizedLabel, " ", fontAwesomeIcon.Html);
            }
            else
            {
                link.InnerHtml = string.Concat(fontAwesomeIcon == null ? string.Empty : fontAwesomeIcon.Html + " ", localizedLabel);
            }

            link.AddCssClass(GetButtonCssClass(type));
            link.AddCssClass("btn");
            AddAdditionalAttributes(htmlAttributes, link);
            return MvcHtmlString.Create(link.ToString(TagRenderMode.Normal));
        }