示例#1
0
        static void Main(string[] args)
        {
            var applicationFolder           = AppDomain.CurrentDomain.BaseDirectory;
            var pdfFormFinder               = new PdfFormFinder(applicationFolder);
            var htmlFormFinder              = new HtmlFormFinder(applicationFolder);
            var formModelFinder             = new FormModelFinder(applicationFolder);
            var pdfFormFillingServiceFinder = new PdfFormFillingServiceFinder(applicationFolder);

            var pathToPdfForm               = pdfFormFinder.GetPath();
            var pathToHtmlForm              = htmlFormFinder.GetPath();
            var pathToFormModel             = formModelFinder.GetPath();
            var pathToPdfFormFillingService = pdfFormFillingServiceFinder.GetPath();

            CopyPdfFormToWebsite(pathToPdfForm);

            var formFields         = GetFormFields(pathToPdfForm);
            var filteredFormFields = FilterFormFields(formFields);

            var formMarkup = GenerateHtmlForFormFields(filteredFormFields);

            UpdateHtmlForm(formMarkup, pathToHtmlForm);

            var formModelContent = GenerateFormModel(formFields, pathToFormModel);

            UpdateFormModel(pathToFormModel, formModelContent);

            var pdfFormFillingServiceContent = GeneratePdfFormFillingService(formFields, pathToPdfFormFillingService);

            UpdatePdfFormFillingService(pathToPdfFormFillingService, pdfFormFillingServiceContent);
        }
示例#2
0
        public void CanReachCSharpFormModelFile()
        {
            var applicationFolder = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
            var formModelFinder   = new FormModelFinder(applicationFolder.FullName);

            var result = formModelFinder.GetPath();
            var file   = new FileInfo(result);

            Assert.True(file.Exists);
            Assert.Equal(@"FormModel.cs", file.Name);
        }
示例#3
0
        public void UpdateFormModel_SourceCodeNotProvided_ShouldThrow()
        {
            var    formModelFinder  = new FormModelFinder(AppDomain.CurrentDomain.BaseDirectory);
            var    pathToFormModel  = formModelFinder.GetPath();
            var    formModelUpdater = new FormModelUpdater();
            Action action           = () => formModelUpdater.UpdateFormModel(pathToFormModel, string.Empty);

            var exception = Assert.Throws <ArgumentException>(action);

            Assert.Equal("Source code is null or empty.", exception.Message);
        }
示例#4
0
        public void CanUpdateFormModel()
        {
            var formModelFinder = new FormModelFinder(AppDomain.CurrentDomain.BaseDirectory);
            var pathToFormModel = formModelFinder.GetPath();
            var formMarkup      = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture);

            var formModelUpdater = new FormModelUpdater();

            var originalContent = File.ReadAllText(pathToFormModel);

            Assert.DoesNotContain(formMarkup, originalContent);

            formModelUpdater.UpdateFormModel(pathToFormModel, formMarkup);

            var updatedContent = File.ReadAllText(pathToFormModel);

            Assert.Contains(formMarkup, updatedContent);

            //revert
            File.WriteAllText(pathToFormModel, originalContent);
            var revertedContent = File.ReadAllText(pathToFormModel);

            Assert.DoesNotContain(formMarkup, revertedContent);
        }