コード例 #1
0
        public void MultipleFormFields_CanGenerateFormModel()
        {
            var expectedResult = @"
namespace PDFiller.CodeGeneration.Tests.SampleCodeFiles
{
    class SampleFormModel
    {
        [Required]
        public string First { get; set; }

        [Required]
        public bool Second { get; set; }
    }
}".TrimStart(_newLineChars);

            var formFields = new List <FormField>
            {
                new FormField("First", FormFieldType.TextBox),
                new FormField("Second", FormFieldType.CheckBox),
            };

            var formModelGenerator = new FormFieldPropertyGenerator(formFields);
            var result             = formModelGenerator.Visit(_syntaxTree.GetRoot()).ToFullString();

            Assert.Equal(expectedResult, result);
        }
コード例 #2
0
        public void FormFieldListEmpty_ReturnsUnchangedModel()
        {
            var expectedResult = @"
namespace PDFiller.CodeGeneration.Tests.SampleCodeFiles
{
    class SampleFormModel
    {
    }
}".TrimStart(_newLineChars);

            var formModelGenerator = new FormFieldPropertyGenerator(new List <FormField>());
            var result             = formModelGenerator.Visit(_syntaxTree.GetRoot()).ToFullString();

            Assert.Equal(expectedResult, result);
        }