示例#1
0
    public void BitIconButtonTest(Visual visual, bool isEnabled, BitIconName iconName, string title)
    {
        var com = RenderComponent <BitIconButtonTest>(parameters =>
        {
            parameters.Add(p => p.Visual, visual);
            parameters.Add(p => p.IsEnabled, isEnabled);
            parameters.Add(p => p.IconName, iconName);
            parameters.Add(p => p.Title, title);
        });

        var bitIconButton = com.Find(".bit-ico-btn");
        var bitIconITag   = com.Find(".bit-ico-btn > span > i");

        var isEnabledClass = isEnabled ? "enabled" : "disabled";
        var visualClass    = visual == Visual.Cupertino ? "cupertino" : visual == Visual.Material ? "material" : "fluent";

        Assert.IsTrue(bitIconButton.ClassList.Contains($"bit-ico-btn-{isEnabledClass}-{visualClass}"));

        Assert.IsTrue(bitIconITag.ClassList.Contains($"bit-icon--{iconName.GetName()}"));

        if (title.HasValue())
        {
            Assert.IsTrue(bitIconButton.GetAttribute("title").Contains(title));
        }

        bitIconButton.Click();

        Assert.AreEqual(isEnabled ? 1 : 0, com.Instance.CurrentCount);
    }
示例#2
0
    public void BitCheckboxCustomCheckmarkIconTest(BitIconName checkmarkIconName)
    {
        var component = RenderComponent <BitCheckboxTest>(parameters =>
        {
            parameters.Add(p => p.CheckmarkIconName, checkmarkIconName);
        });

        var icon = component.Find(".bit-chb-checkmark");

        Assert.IsTrue(icon.ClassList.Contains($"bit-icon--{checkmarkIconName.GetName()}"));
    }
示例#3
0
    public void BitRadioButtonOptionShouldrespectIcon(BitIconName iconName)
    {
        var component = RenderComponent <BitRadioButtonGroupTest>(
            parameters =>
        {
            parameters.Add(p => p.IconName, iconName);
        });

        var icon = component.Find(".bit-rbo-icon-wrapper i");

        Assert.IsTrue(icon.ClassList.Contains($"bit-icon--{iconName.GetName()}"));
    }
    public void BitSpinButtonShoudRenderCorrectIncrementButton(BitIconName iconName, string iconAriaLabel, bool isEnabled)
    {
        var component = RenderComponent <BitSpinButtonTest>(parameters =>
        {
            parameters.Add(p => p.IncrementButtonIconName, iconName);
            parameters.Add(p => p.IncrementButtonAriaLabel, iconAriaLabel);
            parameters.Add(p => p.IsEnabled, isEnabled);
        });

        var button = component.Find("button");
        var icon   = component.Find("button > span > i");

        Assert.IsTrue(icon.ClassList.Contains($"bit-icon--{iconName.GetName()}"));
        Assert.AreEqual(!isEnabled, button.HasAttribute("disabled"));
        Assert.AreEqual(!isEnabled, button.HasAttribute("aria-disabled"));

        if (iconAriaLabel is not null)
        {
            Assert.AreEqual(iconAriaLabel, button.GetAttribute("aria-label"));
        }
    }
    public void BitRatingShouldRespectDefaultRatingValue(int max, double defaultValue, BitIconName icon, BitIconName unselectedIcon)
    {
        var component = RenderComponent <BitRatingTest>(parameters =>
        {
            parameters.Add(p => p.DefaultValue, defaultValue);
            parameters.Add(p => p.Max, max);
        });

        var buttons = component.FindAll(".bit-rating button i:nth-child(2)");

        var filledBitRatingIconCount     = buttons.Where(s => s.ClassList.Contains($"bit-icon--{icon.GetName()}")).Count();
        var unselectedBitRatingIconCount = buttons.Where(s => s.ClassList.Contains($"bit-icon--{unselectedIcon.GetName()}")).Count();

        //TODO: bypassed - BUnit 2-way bound parameters issue
        //Assert.AreEqual(filledBitRatingIconCount, defaultValue);
        //Assert.AreEqual(unselectedBitRatingIconCount, max - defaultValue);
    }