Ejemplo n.º 1
0
        public async Task ThrowsOnFirstRenderIfInputRadioHasNoGroup()
        {
            var model         = new TestModel();
            var rootComponent = new TestInputRadioHostComponent <TestEnum>
            {
                EditContext  = new EditContext(model),
                InnerContent = RadioButtonsWithoutGroup(null)
            };

            var ex = await Assert.ThrowsAsync <InvalidOperationException>(() => RenderAndGetTestInputComponentAsync(rootComponent));

            Assert.Contains($"must have an ancestor", ex.Message);
        }
Ejemplo n.º 2
0
        public async Task GroupGeneratesNameGuidWhenInvalidNameSupplied()
        {
            var model         = new TestModel();
            var rootComponent = new TestInputRadioHostComponent <TestEnum>
            {
                EditContext  = new EditContext(model),
                InnerContent = RadioButtonsWithGroup(null, () => model.TestEnum)
            };

            var inputRadioComponents = await RenderAndGetTestInputComponentAsync(rootComponent);

            Assert.All(inputRadioComponents, inputRadio => Assert.True(Guid.TryParseExact(inputRadio.GroupName, "N", out _)));
        }
Ejemplo n.º 3
0
    public async Task InputElementIsAssignedSuccessfully()
    {
        var model         = new TestModel();
        var rootComponent = new TestInputRadioHostComponent <TestEnum>
        {
            EditContext  = new EditContext(model),
            InnerContent = RadioButtonsWithGroup(null, () => model.TestEnum)
        };

        var inputRadioComponents = await RenderAndGetTestInputComponentAsync(rootComponent);

        Assert.All(inputRadioComponents, inputRadio => Assert.NotNull(inputRadio.Element));
    }
Ejemplo n.º 4
0
        public async Task RadioInputContextExistsWhenValidNameSupplied()
        {
            var groupName     = "group";
            var model         = new TestModel();
            var rootComponent = new TestInputRadioHostComponent <TestEnum>
            {
                EditContext  = new EditContext(model),
                InnerContent = RadioButtonsWithGroup(groupName, () => model.TestEnum)
            };

            var inputRadioComponents = await RenderAndGetTestInputComponentAsync(rootComponent);

            Assert.All(inputRadioComponents, inputRadio => Assert.Equal(groupName, inputRadio.GroupName));
        }
Ejemplo n.º 5
0
        private static async Task <IEnumerable <TestInputRadio> > RenderAndGetTestInputComponentAsync(TestInputRadioHostComponent <TestEnum> rootComponent)
        {
            var testRenderer = new TestRenderer();
            var componentId  = testRenderer.AssignRootComponentId(rootComponent);
            await testRenderer.RenderRootComponentAsync(componentId);

            return(FindInputRadioComponents(testRenderer.Batches.Single()));
        }