コード例 #1
0
        public void OpenFieldset_AlreadyGotItem_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new DateInputContext(haveExplicitValue: false);

            var item = new DateInputContextItem()
            {
                LabelContent = new HtmlString("Day")
            };

            context.SetItem(DateInputItemType.Day, item);

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

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("<govuk-date-input-fieldset> must be the only direct child of the <govuk-date-input>.", ex.Message);
        }
コード例 #2
0
        public void SetHint_AlreadyGotItem_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new DateInputContext(haveExplicitValue: false);

            var item = new DateInputContextItem()
            {
                LabelContent = new HtmlString("Day")
            };

            context.SetItem(DateInputItemType.Day, item);

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

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("<govuk-date-input-hint> must be specified before <govuk-date-input-day>.", ex.Message);
        }
コード例 #3
0
        public void SetHint_OutsideOfFieldset_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new DateInputContext(haveExplicitValue: false);

            var item = new DateInputContextItem()
            {
                LabelContent = new HtmlString("Day")
            };

            context.OpenFieldset();
            var fieldsetContext = new DateInputFieldsetContext(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-date-input-hint> must be inside <govuk-date-input-fieldset>.", ex.Message);
        }