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); }
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); }
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); }
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); }