Example #1
0
        public void MudPopoverHandler_UpdateAndLockCycle()
        {
            RenderFragment initialRenderFragement = (tree) => { };
            var            mock = Mock.Of <IJSRuntime>();

            var    updateCounter = 0;
            Action updater       = () => { updateCounter++; };

            var handler = new MudPopoverHandler(initialRenderFragement, mock, updater);

            var comp = Context.RenderComponent <MudBadge>(p =>
            {
                p.Add(x => x.UserAttributes, new Dictionary <string, object> {
                    { "myprop1", "myValue1" }
                });
                p.Add(x => x.Tag, "my tag");
            });

            RenderFragment newRenderFragement = (tree) => { };

            for (int i = 0; i < 4; i++)
            {
                handler.UpdateFragment(newRenderFragement, comp.Instance, "my-extra-class", "my-extra-style:2px", i % 2 == 0);
            }
            updateCounter.Should().Be(1);

            handler.Release();

            handler.UpdateFragment(newRenderFragement, comp.Instance, "my-new-extra-class", "my-new-extra-style:2px", true);

            updateCounter.Should().Be(2);

            handler.Class.Should().Be("my-new-extra-class");
            handler.Style.Should().Be("my-new-extra-style:2px");
        }
Example #2
0
        public void MudPopoverHandler_UpdateFragment()
        {
            RenderFragment initialRenderFragement = (tree) => { };
            var            mock = Mock.Of <IJSRuntime>();

            var    updateCounter = 0;
            Action updater       = () => { updateCounter++; };

            var handler = new MudPopoverHandler(initialRenderFragement, mock, updater);

            var comp = Context.RenderComponent <MudBadge>(p =>
            {
                p.Add(x => x.UserAttributes, new Dictionary <string, object> {
                    { "myprop1", "myValue1" }
                });
                p.Add(x => x.Tag, "my tag");
            });

            RenderFragment newRenderFragement = (tree) => { };

            handler.UpdateFragment(newRenderFragement, comp.Instance, "my-extra-class", "my-extra-style:2px", true);

            handler.Id.Should().NotBe(default(Guid));
            handler.UserAttributes.Should().BeEquivalentTo(new Dictionary <string, object> {
                { "myprop1", "myValue1" }
            });
            handler.Class.Should().Be("my-extra-class");
            handler.Style.Should().Be("my-extra-style:2px");
            handler.Tag.Should().Be("my tag");
            handler.Fragment.Should().BeSameAs(newRenderFragement);
            handler.IsConnected.Should().BeFalse();
            handler.ShowContent.Should().BeTrue();

            updateCounter.Should().Be(1);
        }