예제 #1
0
        public void OpenFieldset_AlreadyGotHint_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new CheckboxesContext(name: null, aspFor: null);

            context.SetHint(attributes: null, content: new HtmlString("Hint"));

            // Act
            var ex = Record.Exception(() => context.OpenFieldset());

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("<govuk-checkboxes-fieldset> must be the only direct child of the <govuk-checkboxes>.", ex.Message);
        }
예제 #2
0
        public void SetHint_AlreadyGotItem_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new CheckboxesContext(name: null, aspFor: null);

            var item = new CheckboxesItem()
            {
                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-checkboxes-hint> must be specified before <govuk-checkboxes-item>.", ex.Message);
        }
예제 #3
0
        public void SetHint_OutsideOfFieldset_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new CheckboxesContext(name: null, aspFor: null);

            var item = new CheckboxesItem()
            {
                LabelContent = new HtmlString("Item 1"),
                Value        = "item1"
            };

            context.OpenFieldset();
            var fieldsetContext = new CheckboxesFieldsetContext(attributes: null);

            context.CloseFieldset(fieldsetContext);

            // Act
            var ex = Record.Exception(() => context.SetHint(attributes: null, new HtmlString("Hint")));

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("<govuk-checkboxes-hint> must be inside <govuk-checkboxes-fieldset>.", ex.Message);
        }