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)); } }
public async Task ToTheNewColor( Color startColor, Color targetColor, bool isPrimary, bool isSecondary, bool isSuccess, bool isInfo, bool isWarning, bool isDanger, bool isLight, bool isDark, bool isLink) { // Arrange IRenderedComponent <BSButton> cut = RenderComponent <BSButton>( (ButtonApi.Color, startColor)); // Act cut.SetParametersAndRender(prm => prm.Add(p => p.Color, targetColor)); // Assert cut.Find(HtmlTags.Button); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.Btn); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnPrimary).Should().Be(isPrimary); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnSecondary).Should().Be(isSecondary); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnSuccess).Should().Be(isSuccess); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnInfo).Should().Be(isInfo); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnWarning).Should().Be(isWarning); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnDanger).Should().Be(isDanger); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnLight).Should().Be(isLight); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnDark).Should().Be(isDark); cut.Find(HtmlTags.Button).ToMarkup().Contains(ButtonCss.BtnLink).Should().Be(isLink); }
public async Task ChangeKindState( string startState, string endState, bool isPrimary, bool isSecondary, bool isTertiary, bool isDanger, bool isGhost) { // Arrange IRenderedComponent <BcButton> cut = RenderComponent <BcButton>( (ButtonApi.Kind, startState)); // Act cut.SetParametersAndRender(pr => pr.Add(p => p.Kind, endState)); // Assert cut.Find(HtmlElements.Button); cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnKindPrimary).Should() .Be(isPrimary); cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnKindSecondary).Should() .Be(isSecondary); cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnKindTertiary).Should() .Be(isTertiary); cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnKindDanger).Should() .Be(isDanger); cut.Find(HtmlElements.Button).ToMarkup().Contains(CarbonDesignSystemCss.Button.BxBtnKindGhost).Should() .Be(isGhost); }
public async Task Change_EnabledDisabledState( bool startState, bool endState, bool result) { // Arrange IRenderedComponent <BcButton> cut = RenderComponent <BcButton>( (ButtonApi.IsDisabled, startState)); // Act cut.SetParametersAndRender(parameters => parameters.Add(p => p.IsDisabled, endState)); // Assert cut.Find(HtmlElements.Button).ToMarkup().Contains("disabled").Should().Be(result); }
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); }