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
 public void PrintDocuments(IEnumerable <IDocument> documents)
 {
     foreach (var document in documents)
     {
         var printableDocument = PrintableDocument.Create(document);
         printableDocument.Print(printer);
     }
 }
Beispiel #3
0
        NewDocument_WithDefaultEmptyConstructor_ShouldInitializeDocumentBuilderAndFileWriterAndNotThrowException()
        {
            var document = new PrintableDocument <ITestPrintableDocument>();

            var printableDocument = document.Create("Test");

            Assert.AreEqual("Test", printableDocument.Title);
        }
Beispiel #4
0
        public void Create_ReturnsMatchingProperties()
        {
            var source = TestUtils.CreateRandom <StubDocument>();

            var actual = PrintableDocument.Create(source);

            Assert.That(actual.DocumentType, Is.EqualTo(source.DocumentType));
            Assert.That(actual.Path, Is.EqualTo(source.Path));
        }
Beispiel #5
0
        /// <summary>
        /// Creates the documentation body content for the given MsBuild target
        /// </summary>
        /// <param name="target">The target for which the documentation should be generated.</param>
        /// <returns>Document representing the generated documentation</returns>
        public IPrintableDocument CreateOverview(IMsBuildTarget target)
        {
            IPrintableDocument targetOverviewDocument = _printableDocument.Create(target.Name);

            AppendDescriptionSection(targetOverviewDocument, target);
            AppendParameterSection(targetOverviewDocument, target);
            AppendOutputSection(targetOverviewDocument, target);
            AppendDependencySection(targetOverviewDocument, target);
            AppendErrorHandlingSection(targetOverviewDocument, target);
            AppendExampleSection(targetOverviewDocument, target);

            return(targetOverviewDocument);
        }
Beispiel #6
0
        public void NewDocument_WithExistentPrintableDocumentType_ShouldCallCreateMethodOnFactory()
        {
            var testPrintableDocument = new Mock <ITestPrintableDocument>();

            var documentBuilderMock = new Mock <IFormattableDocumentBuilder>();

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

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

            document.Create("Title");

            documentBuilderMock.Verify(db => db.Build <ITestPrintableDocument>(), Times.Exactly(1));
        }
Beispiel #7
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>()));
        }
Beispiel #8
0
        public void NewDocument_WithExistentPrintableDocumentTypeAndTitle_ShouldCallSetTitleOnPrintableDocument()
        {
            var testPrintableDocument = new Mock <ITestPrintableDocument>();

            var documentBuilderMock = new Mock <IFormattableDocumentBuilder>();

            documentBuilderMock.Setup(db => db.Build <ITestPrintableDocument>()).Returns(testPrintableDocument.Object);
            testPrintableDocument.SetupSet(tpd => tpd.Title = It.IsAny <string>()).Verifiable();

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

            document.Create("Title");

            testPrintableDocument.VerifySet(tpd => tpd.Title = It.Is <string>(s => s.Equals("Title")));
        }
Beispiel #9
0
 /// <summary>
 /// Creates the output file from the document builder for the given generic type.
 /// </summary>
 /// <param name="file">The file for which the output documentation file should be created</param>
 /// <param name="printableDocument">The document builder which is used for creating the output file</param>
 /// <returns>Instance of the requested generic type</returns>
 private IPrintableDocument CreateOutputDocument(IFile file, PrintableDocument <T> printableDocument)
 {
     return(printableDocument.Create(file.FileName));
 }
Beispiel #10
0
 private PrintableDocument CreateRandomDocument()
 {
     return(PrintableDocument.Create(TestUtils.CreateRandom <StubDocument>()));
 }