public async Task Splat_Attributes()
        {
            // Arrange
            IRenderedComponent <BfTreeView> cut = RenderComponent <BfTreeView>(
                p => p.AddChildContent <BfTreeItem>(
                    pa =>
            {
                pa.AddUnmatched("custom", "value");
                pa.AddUnmatched("custom2", "value2");
            }));

            // Assert
            cut.Find(BfComponentApis.BfTreeItem.Html.BfTreeItem)
            .Attributes
            .GetNamedItem("custom")
            .Value
            .Should()
            .Be("value");

            cut.Find(BfComponentApis.BfTreeItem.Html.BfTreeItem)
            .Attributes
            .GetNamedItem("custom2")
            .Value
            .Should()
            .Be("value2");
        }
        public async Task BeEnabled_ByDefault()
        {
            // Arrange
            IRenderedComponent <BcButton> cut = RenderComponent <BcButton>();

            // Assert
            cut.Find(HtmlElements.Button).ToMarkup().Contains("enabled").Should().BeFalse();
            cut.Find(HtmlElements.Button).ToMarkup().Contains("disabled").Should().BeFalse();
        }
        public async Task BeEnabled_WhenEnabledStateIsConfigured()
        {
            // Arrange
            IRenderedComponent <BcButton> cut = RenderComponent <BcButton>(
                (ButtonApi.IsDisabled, false));

            // Assert
            cut.Find(HtmlElements.Button).ToMarkup().Contains("enabled").Should().BeFalse();
            cut.Find(HtmlElements.Button).ToMarkup().Contains("disabled").Should().BeFalse();
        }
        public async Task Primary_WhenNoColorIsSetUp()
        {
            // Arrange
            IRenderedComponent <BSButton> cut = RenderComponent <BSButton>();

            // Assert
            cut.Find(HtmlTags.Button);
            cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.Btn).Should().BeTrue();
            cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnPrimary).Should().BeTrue();
        }
Beispiel #5
0
        // It has to be checked in the doc
        public async Task BePrimary_ByDefault()
        {
            // Arrange
            IRenderedComponent <BcButton> cut = RenderComponent <BcButton>();

            // Assert
            cut.Find(HtmlElements.Button);
            cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnKindPrimary).Should()
            .BeTrue();
        }
        public async Task Primary_WhenItConfiguredToBePrimary()
        {
            // Arrange
            IRenderedComponent <BSButton> cut = RenderComponent <BSButton>(
                (ButtonApi.Color, Color.Primary));

            // Assert
            cut.Find(HtmlTags.Button);
            cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.Btn).Should().BeTrue();
            cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnPrimary).Should().BeTrue();
        }
        public async Task Danger_WhenColorConfiguredToDanger()
        {
            // Arrange
            IRenderedComponent <BSButton> cut = RenderComponent <BSButton>(
                (ButtonApi.Color, Color.Danger));

            // Assert
            cut.Find(HtmlTags.Button);
            cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.Btn).Should().BeTrue();
            cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnDanger).Should().BeTrue();
        }
Beispiel #8
0
        public async Task BeTertiary_WhenItIsConfiguredAccordingly()
        {
            // Arrange
            IRenderedComponent <BcButton> cut = RenderComponent <BcButton>(
                (ButtonApi.Kind, BcButtonApi.Kind.Tertiary));

            // Assert
            cut.Find(HtmlElements.Button);
            cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnKindTertiary).Should()
            .BeTrue();
        }
Beispiel #9
0
        public void Test1()
        {
            using TestContext context = new();
            IRenderedComponent <NavMenu> navMenu = context.RenderComponent <NavMenu>();

            Assert.True(navMenu.Find(".NavMenuWrapper").ClassList.Contains("collapse"));

            navMenu.Find(".navbar-toggler").Click();

            Assert.False(navMenu.Find(".NavMenuWrapper").ClassList.Contains("collapse"));
        }
        private void VerifyGridColumnCount <T>(IRenderedComponent <BlazorGrid <T> > grid, int expectedColumnCount)
            where T : class
        {
            Assert.AreEqual(expectedColumnCount, grid.Instance.Columns.Count());

            // Verify number of th's
            var header = grid.Find(".grid-row.grid-header");

            Assert.AreEqual(expectedColumnCount, header.Children.Count());

            // Verify number of td's per row
            var row = grid.Find(".grid-row:not(.grid-header)");

            Assert.AreEqual(expectedColumnCount, row.Children.Count());
        }
        public async Task Div_Splatting_MultipleUnknowParameters()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>(
                bca =>
            {
                bca.AddChildContent <BcAccordionItem>(bcai =>
                {
                    bcai.AddChildContent <BcAccordionTitle>(bcat =>
                    {
                        bcat.AddUnmatched("custom", "value");
                        bcat.AddUnmatched("custom1", "value1");
                        bcat.AddChildContent("Title");
                    });
                });
            });

            // Assert
            IElement div = cut.Find("button>div");

            div.Attributes.GetNamedItem("custom")
            .Value
            .Should().Be("value");
            div.Attributes.GetNamedItem("custom1")
            .Value
            .Should().Be("value1");
        }
        public void LoadingElement_should_rendered_correctly_loading_state()
        {
            IRenderedComponent <LoadingElement> rendered = null;

            rendered = _testContext.RenderComponent <LoadingElement>(parameters => parameters
                                                                     .Add(p => p.IsLoading, false)
                                                                     .Add(p => p.Content, (RenderFragment)(builder =>
            {
                builder.AddMarkupContent(1, "<div>Content</div>");
            }))
                                                                     .Add(p => p.LoadingContent, (RenderFragment)(builder =>
            {
                builder.AddMarkupContent(1, "loading...");
            }))
                                                                     .Add(p => p.OnLoading, async args => { await CheckLoading(); }));

            rendered.SetParametersAndRender(parameters => parameters
                                            .Add(p => p.IsLoading, true));

            var div = rendered.Find("div");

            Assert.IsNotNull(div);

            async Task CheckLoading()
            {
                await Task.Delay(200);

                rendered.WaitForAssertion(() =>
                                          rendered.MarkupMatches(@"<div class=""loading"" style=""background-color: rgba(128, 128, 128, 0.9)""><div class=""loading-content"">loading...</div><div>Content</div></div>"),
                                          timeout: TimeSpan.FromSeconds(1));
            }
        }
Beispiel #13
0
        public async Task Splatting_MultipleUnknowParameters()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>(
                bca =>
            {
                bca.AddChildContent <BcAccordionItem>(bcai =>
                {
                    bcai.AddChildContent <BcAccordionContent>(bcaic =>
                    {
                        bcaic.AddUnmatched("custom", "value");
                        bcaic.AddUnmatched("custom1", "value1");
                        bcaic.AddChildContent("Something stuff");
                    });
                });
            });

            // Assert
            IElement con = cut.Find("ul>li>div");

            con.Attributes.GetNamedItem("custom").Value
            .Should().Be("value");
            con.Attributes.GetNamedItem("custom1").Value
            .Should().Be("value1");
        }
        public void LoadingButton_should_rendered_correctly_loading_state()         //Incomplete test for technical reasons...
        {
            IRenderedComponent <LoadingButton> rendered = null;

            rendered = _testContext.RenderComponent <LoadingButton>(parameters => parameters
                                                                    .Add(p => p.Type, ButtonTypes.Submit)
                                                                    .Add(p => p.Content, (RenderFragment)(builder =>
            {
                builder.AddMarkupContent(1, "hello...");
            }))
                                                                    .Add(p => p.LoadingContent, (RenderFragment)(builder =>
            {
                builder.AddMarkupContent(1, "loading...");
            }))
                                                                    .Add(p => p.OnClicked, async args => { await CheckClick(); }));

            var button = rendered.Find("button");

            button.Click();

            Assert.IsNotNull(button);

            async Task CheckClick()
            {
                await Task.Delay(200);

                rendered.WaitForAssertion(() =>
                                          rendered.MarkupMatches("<button blazor:onclick=\"1\" type=\"submit\" disabled=\"\">loading...</button>"),
                                          timeout: TimeSpan.FromSeconds(1));
            }
        }
Beispiel #15
0
        public async Task Be_A_LiItem()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>();

            // Assert
            cut.Find(HtmlElements.Ul);
        }
Beispiel #16
0
        public async Task TestWithInvalidCredentials()
        {
            instance.email = instance.password = null;
            var result = await instance.AuthenticateUser();

            Assert.False(result);
            component.WaitForState(() => component.Find("#loginButton") != null, TimeSpan.FromSeconds(10));//todo remover
        }
Beispiel #17
0
        public async Task Splatting_MultipleUnknownAttributes()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>(
                ("custom", "custom-value"),
                ("custom2", "custom-value2"));

            // Assert
            cut.Find(HtmlElements.Ul).ToMarkup()
            .Contains("custom=\"custom-value\"")
            .Should()
            .BeTrue();

            cut.Find(HtmlElements.Ul).ToMarkup()
            .Contains("custom2=\"custom-value2\"")
            .Should()
            .BeTrue();
        }
        public async Task Generate_FastTreeView_HtmlItem()
        {
            // Act
            IRenderedComponent <BfTreeView> cut = RenderComponent <BfTreeView>();

            // Assert
            cut.Find(BfComponentApis.BfTreeView.Html.BfTreeView)
            .Should().NotBeNull();
        }
Beispiel #19
0
        public TimeSpan TimeLeft()
        {
            _index.Render();
            var timeLeft  = _index.Find(".timer").Text();
            var timeParts = timeLeft.Split(':').Select(int.Parse).ToArray();

            return(new TimeSpan(0, timeParts[0], timeParts[1]));
        }
        public async Task Have_ButtonElem()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>(
                bca =>
            {
                bca.AddChildContent <BcAccordionItem>(bcai =>
                {
                    bcai.AddChildContent <BcAccordionTitle>(bcat => { bcat.AddChildContent("Title"); });
                });
            });

            // Assert
            cut.Find(HtmlElements.Button);
            cut.Find(HtmlElements.Button).ToMarkup()
            .Contains("Title")
            .Should()
            .BeTrue();
        }
Beispiel #21
0
        public async Task BeClosed_ByDefault()
        {
            // Arrange
            IRenderedComponent <BfAccordion> cut = RenderComponent <BfAccordion>(
                p => p.AddChildContent <BfAccordionItem>());

            // Assert
            cut.Find($"{FastHtmlElements.FastAccordion}>{FastHtmlElements.FastAccordionItem}")
            .ClassList.Length.Should().Be(0);
        }
        public async Task Enabled_WhenClickOnItAndItWasDisabled()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>(
                p => p.AddChildContent <BcAccordionItem>(b =>
            {
                b.Add(p => p.IsActive, false);
                b.AddChildContent <BcAccordionTitle>();
            }));
            IElement button = cut.Find(HtmlElements.Button);

            // Act
            button.Click();

            // Assert
            cut.Find(HtmlElements.Li).ToMarkup()
            .Contains(CarbonDesignSystemCss.Accordion.BxAccordionItemActive)
            .Should()
            .BeTrue();
        }
Beispiel #23
0
        public async Task Have_DataAccordionProperty()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>();

            // Assert
            cut.Find(HtmlElements.Ul).ToMarkup()
            .Contains("data-accordion")
            .Should()
            .BeTrue();
        }
Beispiel #24
0
        public async Task HaveTheRight_CssClasses()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>();

            // Assert
            cut.Find(HtmlElements.Ul).ToMarkup()
            .Contains(CarbonDesignSystemCss.Accordion.BxAccordion)
            .Should()
            .BeTrue();
        }
        public async Task BeDefault_ByDefault(
            string startState,
            string endState,
            bool isField,
            bool isSmall)
        {
            // Arrange
            IRenderedComponent <BcButton> cut = RenderComponent <BcButton>(
                (ButtonApi.Size, startState));

            // Act
            cut.SetParametersAndRender(parameters => parameters.Add(p => p.Size, endState));

            // Assert
            cut.Find(HtmlElements.Button);
            cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnSizeSmall).Should()
            .Be(isSmall);
            cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnSizeField).Should().Be
                (isField);
        }
Beispiel #26
0
        public async Task HaveNoCssClasses()
        {
            // Arrange
            IRenderedComponent <BfAccordion> cut = RenderComponent <BfAccordion>();

            // Assert
            cut.Find(FastHtmlElements.FastAccordion)
            .ClassList.Length
            .Should()
            .Be(0);
        }
        public async Task Enabled_WhenItisConfigureSo()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>(
                p => p.AddChildContent <BcAccordionItem>(b => { b.Add(p => p.IsActive, true); }));

            // Assert
            cut.Find(HtmlElements.Li).ToMarkup()
            .Contains(CarbonDesignSystemCss.Accordion.BxAccordionItemActive)
            .Should()
            .BeTrue();
        }
Beispiel #28
0
 /// <summary>
 ///   Flips when Find throws
 /// </summary>
 /// <param name="rendered">Rendered tree to use</param>
 /// <param name="cssSelector">What element to look for</param>
 /// <typeparam name="T">Rendered component type</typeparam>
 /// <exception cref="InvalidOperationException">Thrown when the element is found</exception>
 public static void FindIsNull <T>(this IRenderedComponent <T> rendered, string cssSelector)
     where T : IComponent
 {
     try
     {
         rendered.Find(cssSelector);
         throw new InvalidOperationException("element exists");
     }
     catch (ElementNotFoundException)
     {
     }
 }
        public async Task Render_FastTreeItem_Tag()
        {
            // Arrange
            IRenderedComponent <BfTreeView> cut = RenderComponent <BfTreeView>(
                p => p.AddChildContent <BfTreeItem>()
                );

            // Assert
            cut.Find(BfComponentApis.BfTreeItem.Html.BfTreeItem)
            .Should()
            .NotBeNull();
        }
        public async Task Disabled_ByDefault()
        {
            // Arrange
            IRenderedComponent <BcAccordion> cut = RenderComponent <BcAccordion>(
                p => p.AddChildContent <BcAccordionItem>());

            // Assert
            cut.Find(HtmlElements.Li).ToMarkup()
            .Contains(CarbonDesignSystemCss.Accordion.BxAccordionItemActive)
            .Should()
            .BeFalse();
        }