コード例 #1
0
        public void SetLabel_AlreadyGotLabel_ThrowsInvalidOperationException()
        {
            // Arrange
            var context = new DateInputItemContext("govuk-date-input-day", "govuk-date-input-day-label");

            context.SetLabel(content: new HtmlString("Existing label"), attributes: new AttributeDictionary());

            // Act
            var ex = Record.Exception(() => context.SetLabel(content: new HtmlString("Label"), attributes: new AttributeDictionary()));

            // Assert
            Assert.IsType <InvalidOperationException>(ex);
            Assert.Equal("Only one <govuk-date-input-day-label> element is permitted within each <govuk-date-input-day>.", ex.Message);
        }
コード例 #2
0
        public void SetLabel_SetsLabelOnContext()
        {
            // Arrange
            var context = new DateInputItemContext("govuk-date-input-day", "govuk-date-input-day-label");

            // Act
            context.SetLabel(content: new HtmlString("Label"), attributes: new AttributeDictionary());

            // Assert
            Assert.Equal("Label", context.Label?.Content?.RenderToString());
        }