コード例 #1
0
        public void ValidateObject_ShouldFailValidation(string ssn)
        {
            // Arrange
            var attribute = new SSNValidationAttribute();
            // Act
            var result = attribute.IsValid(ssn);

            // Assert
            Assert.IsFalse(result);
        }
コード例 #2
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public Task <string> RenderAsync(string model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            if (model != null && model.Length == 9)
            {
                hb.Append($@"
<div class='yt_ssn t_display'>
    {HE(SSNValidationAttribute.GetDisplay(model))}
</div>");
            }
            return(Task.FromResult(hb.ToString()));
        }