Example #1
0
        public void SetSuffix_AlreadySet_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new TextInputContext();

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

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

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("Only one <govuk-input-suffix> element is permitted within each <govuk-input>.", ex.Message);
        }
Example #2
0
        public void SetLabel_AlreadyGotSuffix_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new TextInputContext();

            context.SetSuffix(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-suffix>.", ex.Message);
        }