public void IconsFontMaterialIconsExample_Test() { using var ctx = new Bunit.TestContext(); ctx.Services.AddSingleton <NavigationManager>(new MockNavigationManager()); ctx.Services.AddSingleton <IDialogService>(new DialogService()); var comp = ctx.RenderComponent <IconsFontMaterialIconsExample>(); }
public void DrawerPersistentExample_Test() { using var ctx = new Bunit.TestContext(); ctx.Services.AddSingleton <NavigationManager>(new MockNavigationManager()); ctx.Services.AddSingleton <IDialogService>(new DialogService()); var comp = ctx.RenderComponent <DrawerPersistentExample>(); }
public void TextFieldFormPropsExample_Test() { using var ctx = new Bunit.TestContext(); ctx.Services.AddSingleton <NavigationManager>(new MockNavigationManager()); ctx.Services.AddSingleton <IDialogService>(new DialogService()); var comp = ctx.RenderComponent <TextFieldFormPropsExample>(); }
public void MudIconButtonShouldRenderAnAnchorIfLinkIsSet() { using var ctx = new Bunit.TestContext(); var link = Parameter(nameof(MudIconButton.Link), "https://www.google.com"); var target = Parameter(nameof(MudIconButton.Target), "_blank"); var comp = ctx.RenderComponent <MudIconButton>(link, target); //Link property is set, so it has to render an anchor element comp.Instance .HtmlTag .Should() .Be("a"); //Target property is set, so it must have the rel attribute set to noopener comp.Markup .Should() .Contain("rel=\"noopener\""); //it is an anchor comp.Markup .Replace(" ", string.Empty) .Should() .StartWith("<a"); }
public void SwitchWithLabelExample_Test() { using var ctx = new Bunit.TestContext(); ctx.Services.AddSingleton <NavigationManager>(new MockNavigationManager()); ctx.Services.AddSingleton <IDialogService>(new DialogService()); var comp = ctx.RenderComponent <SwitchWithLabelExample>(); }
public void ButtonCustomizedExample_Test() { using var ctx = new Bunit.TestContext(); ctx.Services.AddSingleton <NavigationManager>(new MockNavigationManager()); ctx.Services.AddSingleton <IDialogService>(new DialogService()); var comp = ctx.RenderComponent <ButtonCustomizedExample>(); }
public void Test_CascadingValues() { using var ctx = new Bunit.TestContext(); var cut = ctx.RenderComponent <CascadingValuesExample>(); Assert.IsTrue( cut.Markup.Contains("<label>context-value-one</label>") && cut.Markup.Contains("<label>context-value-two</label>")); }
public void Test_LowkoderFirstExample() { using var ctx = new Bunit.TestContext(); ctx.Services.AddLowKode(config => { config.ContributeMetadataForType <WeatherForecast>(); config.ContributeMetadataForType <Starship>(); }); var cut = ctx.RenderComponent <BasicInputSiteExample>(); cut.Markup.Contains("<h1>Hello world from Blazor</h1>"); }
public void ResetState() { this.BunitTc = new Bunit.TestContext(); BunitTc.Services.AddBlazoredLocalStorage(); BunitTc.Services.AddFluxor(config => config.ScanAssemblies(typeof(RootState).Assembly)); BunitTc.Services.AddScoped <IBookmarksApi>(sp => new MockBookmarksApi()); BunitTc.Services.AddScoped <IBookmarkGroupsApi>(sp => new MockBookmarkGroupsApi()); BunitTc.Services .AddScoped <IBookmarkContainersApi>(sp => new MockBookmarkContainersApi()); this.Store = this.BunitTc.Services.GetRequiredService <IStore>(); this.Dispatcher = this.BunitTc.Services.GetRequiredService <IDispatcher>(); this.State = this.BunitTc.Services.GetRequiredService <IState <RootState> >(); this.Store.InitializeAsync().Wait(); }
public void Test_LowkoderFirstExample() { // Arrange using var ctx = new Bunit.TestContext(); // Register services ctx.Services.AddLowKode(config => { config.ContributeMetadataForType <WeatherForecast>(); config.ContributeMetadataForType <Starship>(); }); // Act var cut = ctx.RenderComponent <LowkoderFirstExample>(); // Assert cut.Markup.Contains("<h1>Hello world from Blazor</h1>"); }
public void MudIconButtonShouldRenderAButtonByDefault() { using var ctx = new Bunit.TestContext(); var comp = ctx.RenderComponent <MudIconButton>(); //no HtmlTag nor Link properties are set, so HtmlTag is button by default comp.Instance .HtmlTag .Should() .Be("button"); //it is a button comp.Markup .Replace(" ", string.Empty) .Should() .StartWith("<button"); }
public void HxInputBase_Renders_WithoutEditContext() { // Arrange var ctx = new Bunit.TestContext(); var formData = new FormData(); RenderFragment componentRenderer = (RenderTreeBuilder builder) => { builder.OpenComponent <HxComponent>(0); builder.AddAttribute(1, "Value", formData.StringValue); builder.AddAttribute(2, "ValueChanged", EventCallback.Factory.Create <string>(this, (value) => { formData.StringValue = value; })); builder.AddAttribute(3, "ValueExpression", (Expression <Func <string> >)(() => formData.StringValue)); builder.CloseComponent(); }; // Act ctx.Render(componentRenderer); // Assert // No exception thrown }
public void MudButtonShouldRenderAButtonByDefault() { using var ctx = new Bunit.TestContext(); var comp = ctx.RenderComponent <MudButton>(); //no HtmlTag nor Link properties are set, so HtmlTag is button by default comp.Instance .HtmlTag .Should() .Be("button"); //it is a button, and has by default stopPropagation on onclick comp.Markup .Replace(" ", string.Empty) .Should() .StartWith("<button") .And .Contain("__internal_stopPropagation_onclick"); }
public void Test_Starship() { // Arrange using var ctx = new Bunit.TestContext(); // Register services ctx.Services.AddLowKode(config => { config.ContributeMetadataForType <WeatherForecast>(); config.ContributeMetadataForType <Starship>(); }); // Act var stopwatch = new Stopwatch(); stopwatch.Start(); var cut = ctx.RenderComponent <StarshipForm>(); stopwatch.Stop(); // Assert Assert.IsTrue(stopwatch.ElapsedMilliseconds < 500); //cut.MarkupMatches("<h1>Hello world from Blazor</h1>"); }
public virtual void Setup() { Context = new(); Context.AddTestServices(); }
public void Setup() { ctx = new Bunit.TestContext(); ctx.AddTestServices(); }
public void InitBase() { _testContext = new Bunit.TestContext(); }