Beispiel #1
0
        public void Save_WithValueOnPrint_CallFileWriterSaveWithCorrectFileContent()
        {
            var outPath        = "/usr/desktop";
            var testPrintValue = "value";

            var testPrintableDocument = new Mock <ITestPrintableDocument>();

            testPrintableDocument.Setup(x => x.Print()).Returns(testPrintValue);

            var documentBuilderMock = new Mock <IFormattableDocumentBuilder>();

            documentBuilderMock.Setup(db => db.Build <ITestPrintableDocument>()).Returns(testPrintableDocument.Object);

            var fileWriterMock = new Mock <IFileWriter>();

            var document =
                new PrintableDocument <ITestPrintableDocument>(documentBuilderMock.Object, fileWriterMock.Object);

            var formattableDocument = document.Create("Title");

            document.Save(outPath, formattableDocument);

            fileWriterMock.Verify(fw =>
                                  fw.WriteAllText(It.IsAny <string>(), It.Is <string>(s => s.Equals(testPrintValue))));
        }
Beispiel #2
0
        /// <summary>
        /// Creates the documentation overview for the given MsBuild project and stores it
        /// into the given output directory.
        /// </summary>
        /// <param name="msBuildProject">The msbuild project to create the documentation for.</param>
        /// <param name="file">The file system entry representing the msbuild project</param>
        /// <param name="outputPath">Directory to store the documentation in</param>
        /// <exception cref="DocumentationGeneratorException">Throws if the body of the documentation could nt be created</exception>
        private void CreateProjectOverview(IMsBuildProject msBuildProject, IFile file,
                                           string outputPath)
        {
            ProjectOverviewGenerator <T> projectOverviewDocumentationGenerator =
                new ProjectOverviewGenerator <T>(msBuildProject, file, _printableDocument);

            if (!projectOverviewDocumentationGenerator.CreateBody())
            {
                throw new DocumentationGeneratorException("Body for project overview could not be created!");
            }

            string outputFilePath = Path.Combine(
                outputPath, string.Format(
                    CultureInfo.InvariantCulture, "{0}.{1}", file.FileName,
                    projectOverviewDocumentationGenerator.OutputDocument.DefaultFileExtension
                    )
                );

            if (!_printableDocument.Save(outputFilePath, projectOverviewDocumentationGenerator.OutputDocument))
            {
                throw new IOException("The documentation could not be saved.");
            }
        }
Beispiel #3
0
        public void Save_WithPathFromPrintableDocument_CallFileWriterSaveWithCorrectPath()
        {
            var outPath = "/usr/desktop";

            var fileWriterMock = new Mock <IFileWriter>();

            var document =
                new PrintableDocument <ITestPrintableDocument>(fileWriterMock.Object);

            IPrintableDocument formattableDocument = document.Create("Title");

            document.Save(outPath, formattableDocument);

            fileWriterMock.Verify(fw => fw.WriteAllText(It.Is <string>(s => s.Equals(outPath)), It.IsAny <string>()));
        }