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); }
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 _))); }
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)); }
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)); }
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())); }