public void AddItem_AddsItemToItems() { // Arrange var context = new RadiosContext(name: null, aspFor: null); var item = new RadiosItem() { LabelContent = new HtmlString("Item 1"), Value = "item1" }; // Act context.AddItem(item); // Assert var contextItem = Assert.Single(context.Items); Assert.Same(item, contextItem); }
public void OpenFieldset_AlreadyGotItem_ThrowsInvalidOperationException() { // Arrange var context = new RadiosContext(name: null, aspFor: null); var item = new RadiosItem() { LabelContent = new HtmlString("Item 1"), Value = "item1" }; context.AddItem(item); // Act var ex = Record.Exception(() => context.OpenFieldset()); // Assert Assert.IsType <InvalidOperationException>(ex); Assert.Equal("<govuk-radios-fieldset> must be the only direct child of the <govuk-radios>.", ex.Message); }
public void SetHint_AlreadyGotItem_ThrowsInvalidOperationException() { // Arrange var context = new RadiosContext(name: null, aspFor: null); var item = new RadiosItem() { LabelContent = new HtmlString("Item 1"), Value = "item1" }; context.AddItem(item); // Act var ex = Record.Exception(() => context.SetHint(attributes: null, new HtmlString("Hint"))); // Assert Assert.IsType <InvalidOperationException>(ex); Assert.Equal("<govuk-radios-hint> must be specified before <govuk-radios-item>.", ex.Message); }
public void AddItem_OutsideOfFieldset_ThrowsInvalidOperationException() { // Arrange var context = new RadiosContext(name: null, aspFor: null); var item = new RadiosItem() { LabelContent = new HtmlString("Item 1"), Value = "item1" }; context.OpenFieldset(); var fieldsetContext = new RadiosFieldsetContext(attributes: null); context.CloseFieldset(fieldsetContext); // Act var ex = Record.Exception(() => context.AddItem(item)); // Assert Assert.IsType <InvalidOperationException>(ex); Assert.Equal("<govuk-radios-item> must be inside <govuk-radios-fieldset>.", ex.Message); }