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 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));
            }
        }
Пример #3
0
        public async Task GenerateTheRightHtml_WithoutAnyParameters()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <Anchor> cut = ctx.RenderComponent <Anchor>();

            // Assert
            cut.MarkupMatches("<fast-anchor appearance=\"hypertext\"></fast-anchor>");
        }
        public void AddOnceValidUriWithAsyncAndDeferEnabled(string uri)
        {
            _ = Services.AddScriptInjection();
            JSInterop.Setup <bool>("window.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.Setup <bool>("Excubo.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.SetupVoid("Excubo.ScriptInjection.Register", (_) => true);
            IRenderedComponent <AddScript> cut = null;

            NUnit.Framework.Assert.DoesNotThrow(() => cut = RenderComponent <AddScript>((nameof(AddScript.Src), uri), (nameof(AddScript.Async), true), (nameof(AddScript.Defer), true)));
            cut.MarkupMatches($@"<script type=""text/javascript"" src=""_content/Excubo.Blazor.ScriptInjection/bootstrap.min.js""></script><script src=""{uri}"" async defer type=""text/javascript"" onload=""window.Excubo.ScriptInjection.Notify('{uri}')""></script>");
        }
Пример #5
0
        public void Generate_ProperHtml_WhenNoParamsSetUp()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <Badge> cut = ctx.RenderComponent <Badge>();

            // Assert
            cut.MarkupMatches("<fast-badge></fast-badge>");
        }
        public async Task GenerateTheRightHtml()
        {
            // Arrange
            using TestContext ctx = new TestContext();

            // Act
            IRenderedComponent <Accordion> cut = ctx.RenderComponent <Accordion>();

            // Assert
            cut.MarkupMatches("<fast-accordion></fast-accordion>");
        }
        public void AddOnceEmpty()
        {
            _ = Services.AddScriptInjection();
            JSInterop.Setup <bool>("window.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.Setup <bool>("Excubo.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.SetupVoid("Excubo.ScriptInjection.Register", (_) => true);
            IRenderedComponent <AddScript> cut = null;

            NUnit.Framework.Assert.DoesNotThrow(() => cut = RenderComponent <AddScript>());
            cut.MarkupMatches("");
        }
        public void AddOnceValidUriWithDeferEnabled(string uri)
        {
            _ = Services.AddScriptInjection(onload_notification: false);
            JSInterop.Setup <bool>("window.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.Setup <bool>("Excubo.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.SetupVoid("Excubo.ScriptInjection.Register", (_) => true);
            IRenderedComponent <AddScript> cut = null;

            NUnit.Framework.Assert.DoesNotThrow(() => cut = RenderComponent <AddScript>((nameof(AddScript.Src), uri), (nameof(AddScript.Defer), true)));
            cut.MarkupMatches($@"<script src=""{uri}"" defer type=""text/javascript""></script>");
        }
Пример #9
0
        public async Task GenerateTheRightHtml()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <AccordionItem> cut = ctx.RenderComponent <AccordionItem>();

            // Assert
            cut.MarkupMatches("<fast-accordion-item><span slot=\"heading\"></span></fast-accordion-item>");
        }
        public async Task GenerateTheRightHtmlWithContent()
        {
            // Arrange
            using TestContext ctx = new TestContext();

            // Act
            IRenderedComponent <Accordion> cut = ctx.RenderComponent <Accordion>(
                parameters => parameters.AddChildContent("childcontent"));

            // Assert
            cut.MarkupMatches("<fast-accordion>childcontent</fast-accordion>");
        }
Пример #11
0
        public async Task GenerateTheRightHtml_WithChildContent()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <Anchor> cut = ctx.RenderComponent <Anchor>(
                parameters => parameters.AddChildContent("childcontent"));

            // Assert
            cut.MarkupMatches("<fast-anchor appearance=\"hypertext\">childcontent</fast-anchor>");
        }
Пример #12
0
        public void Generate_ProperHtml_WhenChildContentIsProvided()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <Badge> cut = ctx.RenderComponent <Badge>(
                p => p.AddChildContent("child-content"));

            // Assert
            cut.MarkupMatches("<fast-badge>child-content</fast-badge>");
        }
Пример #13
0
        public async Task GenerateTheRightHtml_WithUrlParameter()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <Anchor> cut = ctx.RenderComponent <Anchor>(
                parameters => parameters.Add(p => p.Url, "http://example.com"));

            // Assert
            cut.MarkupMatches("<fast-anchor href=\"http://example.com\" appearance=\"hypertext\"></fast-anchor>");
        }
Пример #14
0
        public async Task GenerateTheRightHtml_WithChildContent()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <AccordionItem> cut = ctx.RenderComponent <AccordionItem>(
                parameters => parameters.AddChildContent("childcontent"));

            // Assert
            cut.MarkupMatches("<fast-accordion-item><span slot=\"heading\"></span>childcontent</fast-accordion-item>");
        }
        public void AddTwiceValidUri()
        {
            _ = Services.AddScriptInjection(onload_notification: false);
            JSInterop.Setup <bool>("window.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.Setup <bool>("Excubo.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.SetupVoid("Excubo.ScriptInjection.Register", (_) => true);
            IRenderedComponent <MultipleScriptContainer> cut = null;

            NUnit.Framework.Assert.DoesNotThrow(() => cut = RenderComponent <MultipleScriptContainer>());
            cut.MarkupMatches($@"
<script src=""hello.js"" type=""text/javascript""></script>
<script src=""world.js"" type=""text/javascript"" async></script>");
        }
Пример #16
0
        public void Generate_ProperHtml_WhenChildContentIs_AndColor_AreProvided()
        {
            // Arrange
            using TestContext ctx = new ();

            // Action
            IRenderedComponent <Badge> cut = ctx.RenderComponent <Badge>(
                p => p.AddChildContent("child-content")
                .Add(pr => pr.Color, ComponentApis.Badge.Color.White)
                );

            // Assert
            cut.MarkupMatches("<fast-badge color=\"white\">child-content</fast-badge>");
        }
Пример #17
0
        public void AddTwiceValidUri()
        {
            _ = Services.AddScriptInjection(gzipped_bootstrap: true);
            JSInterop.Setup <bool>("window.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.Setup <bool>("Excubo.hasOwnProperty", (_) => true).SetResult(true);
            JSInterop.SetupVoid("Excubo.ScriptInjection.Register", (_) => true);
            IRenderedComponent <MultipleScriptContainer> cut = null;

            NUnit.Framework.Assert.DoesNotThrow(() => cut = RenderComponent <MultipleScriptContainer>());
            cut.MarkupMatches($@"
<script type=""text/javascript"" src=""_content/Excubo.Blazor.ScriptInjection/bootstrap.min.js.gz""></script>
<script src=""hello.js"" type=""text/javascript"" onload=""window.Excubo.ScriptInjection.Notify('hello.js')""></script>
<script src=""world.js"" type=""text/javascript"" async onload=""window.Excubo.ScriptInjection.Notify('world.js')""></script>");
        }
Пример #18
0
        public void IndexComponentTest()
        {
            IRenderedComponent <Index> cut = RenderComponent <Index>();

            var expectedHtml = @"<h1>Rural Grocery Initiative</h1>
								<p>
								  <br>The mission of the
								  <a href=""https://www.ruralgrocery.org/"">Rural Grocery Initiative</a>
								(RGI) is to provide resources to help sustain and enhance independently-owned rural grocery stores.  RGI assists
									communities and citizens to strengthen rural grocery operations and improve access to healthy foods.
								</p>

								<p>
								This application is meant to aid rural grocers by optimizing their distribution networks. It takes in information about stores or other distribution points
									of interest and will calculate the best way to load trucks, the order to distribute to stores in, etc. The application gives the user control to manipulate
									nodes (a store or distribution center), trucks, demand, and more. To accomplish the routing portion of the calculations, the application utilizes ArcGIS
									Online, a service that can find the best routes between nodes on a map.								
								</p>"                                ;

            cut.MarkupMatches(expectedHtml);
        }