Пример #1
0
        public void SetPrefix_AlreadySet_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new TextInputContext();

            context.SetPrefix(attributes: null, content: new HtmlString("Existing prefix"));

            // Act
            var ex = Record.Exception(() => context.SetPrefix(null, new HtmlString("Prefix")));

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("Only one <govuk-input-prefix> element is permitted within each <govuk-input>.", ex.Message);
        }
Пример #2
0
        public void SetLabel_AlreadyGotPrefix_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new TextInputContext();

            context.SetPrefix(attributes: null, content: new HtmlString("Prefix"));

            // Act
            var ex = Record.Exception(() => context.SetLabel(false, null, new HtmlString("Error")));

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("<govuk-input-label> must be specified before <govuk-input-prefix>.", ex.Message);
        }