public void GenerateResume_OutputPathNotFound_Throws() { // Setup the test. string resumeJsonPath = @"c:\path\resume.json"; string outputPath = @"c:\another\path"; Mock <ITemplate> markdownTemplateMock = new Mock <ITemplate>(); this.fileSystemMock.Setup(fs => fs.FileExists(resumeJsonPath)) .Returns(true); this.fileSystemMock.Setup(fs => fs.DirectoryExists(outputPath)) .Returns(false); try { // Run the test. ResumeController target = new ResumeController(this.serializer, this.markdownConverter, this.pdfGeneratorMock.Object, this.fileSystemMock.Object); target.GenerateResume(resumeJsonPath, outputPath, markdownTemplateMock.Object); } catch (DirectoryNotFoundException ex) { // Validate the results. Assert.AreEqual($"The output directory does not exist: {outputPath}", ex.Message); throw; } }
public void GenerateResume_NullTemplate_Throws() { // Setup the test. string resumeJsonPath = @"c:\path\resume.json"; string outputPath = @"c:\another\path"; ITemplate markdownTemplate = null; try { // Run the test. ResumeController target = new ResumeController(this.serializer, this.markdownConverter, this.pdfGeneratorMock.Object, this.fileSystemMock.Object); target.GenerateResume(resumeJsonPath, outputPath, markdownTemplate); } catch (ArgumentNullException ex) { // Validate the results. Assert.AreEqual(nameof(markdownTemplate), ex.ParamName); throw; } }
public void GenerateResume_EmptyOutputPath_Throws() { // Setup the test. string resumeJsonPath = @"c:\path\resume.json"; string outputPath = string.Empty; Mock <ITemplate> markdownTemplateMock = new Mock <ITemplate>(); try { // Run the test. ResumeController target = new ResumeController(this.serializer, this.markdownConverter, this.pdfGeneratorMock.Object, this.fileSystemMock.Object); target.GenerateResume(resumeJsonPath, outputPath, markdownTemplateMock.Object); } catch (ArgumentException ex) { // Validate the results. Assert.AreEqual(nameof(outputPath), ex.ParamName); throw; } }
/// <summary> /// Generates resumes from the provided JSON file. /// </summary> /// <param name="resumeJsonPath">The path to the JSON document containing the resume data.</param> /// <param name="outputPath">The output path to save the generated resumes to.</param> private static void GenerateResume(string resumeJsonPath, string outputPath) { ResumeController resumeController = new ResumeController(); resumeController.GenerateResume(resumeJsonPath, outputPath); }