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>();
 }
Esempio n. 4
0
        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>"));
        }
Esempio n. 8
0
        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();
        }
Esempio n. 10
0
        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>");
        }
Esempio n. 11
0
        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");
        }
Esempio n. 12
0
            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
            }
Esempio n. 13
0
        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");
        }
Esempio n. 14
0
        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>");
        }
Esempio n. 15
0
 public virtual void Setup()
 {
     Context = new();
     Context.AddTestServices();
 }
Esempio n. 16
0
 public void Setup()
 {
     ctx = new Bunit.TestContext();
     ctx.AddTestServices();
 }
Esempio n. 17
0
 public void InitBase()
 {
     _testContext = new Bunit.TestContext();
 }