Ejemplo n.º 1
0
            public void Should_Throw_If_LogFileContent_Is_WhiteSpace()
            {
                // Given / When
                var result = Record.Exception(() =>
                                              DocFxIssuesSettings.FromContent(" ", @"c:\Source\Cake.Prca\docs"));

                // Then
                result.IsArgumentOutOfRangeException("logFileContent");
            }
Ejemplo n.º 2
0
            public void Should_Throw_If_LogFileContent_Is_Null()
            {
                // Given / When
                var result = Record.Exception(() =>
                                              DocFxIssuesSettings.FromContent(null, @"c:\Source\Cake.Prca\docs"));

                // Then
                result.IsArgumentNullException("logFileContent");
            }
            public void Should_Throw_If_Log_Is_Null()
            {
                // Given / When
                var result = Record.Exception(() =>
                                              new DocFxIssuesProvider(
                                                  null,
                                                  DocFxIssuesSettings.FromContent("Foo", @"c:\Source\Cake.Prca")));

                // Then
                result.IsArgumentNullException("log");
            }
Ejemplo n.º 4
0
            public void Should_Set_LogContent()
            {
                // Given
                var logFileContent = "Foo".ToByteArray();
                var docRootPath    = @"c:\Source\Cake.Issues\docs";

                // When
                var settings = new DocFxIssuesSettings(logFileContent, docRootPath);

                // Then
                settings.LogFileContent.ShouldBe(logFileContent);
            }
Ejemplo n.º 5
0
            public void Should_Set_DocRootPath()
            {
                // Given
                var logFileContent = "Foo".ToByteArray();
                var docRootPath    = @"c:/Source/Cake.Issues/docs";

                // When
                var settings = new DocFxIssuesSettings(logFileContent, docRootPath);

                // Then
                settings.DocRootPath.ToString().ShouldBe(docRootPath);
            }
Ejemplo n.º 6
0
            public void Should_Set_LogFileContent_If_Empty()
            {
                // Given
                byte[] logFileContent = Array.Empty <byte>();
                var    docRootPath    = @"c:\Source\Cake.Issues\docs";

                // When
                var settings = new DocFxIssuesSettings(logFileContent, docRootPath);

                // Then
                settings.LogFileContent.ShouldBe(logFileContent);
            }
Ejemplo n.º 7
0
            public void Should_Set_DocRootPath_From_LogFilePath()
            {
                // Given
                var docRootPath = @"c:/Source/Cake.Issues/docs";

                using (var tempFile = new ResourceTempFile("Cake.Issues.DocFx.Tests.Testfiles.docfx.json"))
                {
                    // When
                    var settings = new DocFxIssuesSettings(tempFile.FileName, docRootPath);

                    // Then
                    settings.DocRootPath.ToString().ShouldBe(docRootPath);
                }
            }
Ejemplo n.º 8
0
            public void Should_Set_LogContent_From_LogFilePath()
            {
                // Given
                var docRootPath = @"c:\Source\Cake.Issues\docs";

                using (var tempFile = new ResourceTempFile("Cake.Issues.DocFx.Tests.Testfiles.docfx.json"))
                {
                    // When
                    var settings = new DocFxIssuesSettings(tempFile.FileName, docRootPath);

                    // Then
                    settings.LogFileContent.ShouldBe(tempFile.Content);
                }
            }
Ejemplo n.º 9
0
            public void Should_Set_DocRootPath()
            {
                // Given
                DirectoryPath docRootPath = @"c:\Source\Cake.Prca\docs";

                // When
                var settings =
                    DocFxIssuesSettings.FromContent(
                        "foo",
                        docRootPath);

                // Then
                settings.DocRootPath.ShouldBe(docRootPath);
            }
Ejemplo n.º 10
0
            public void Should_Set_LogFileContent()
            {
                // Given
                const string logFileContent = "foo";

                // When
                var settings =
                    DocFxIssuesSettings.FromContent(
                        logFileContent,
                        @"c:\Source\Cake.Prca\docs");

                // Then
                settings.LogFileContent.ShouldBe(logFileContent);
            }
Ejemplo n.º 11
0
        public DocFxProviderFixture(string fileResourceName, DirectoryPath docRootPath)
        {
            this.Log = new FakeLog {
                Verbosity = Verbosity.Normal
            };

            using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Prca.Issues.DocFx.Tests.Testfiles." + fileResourceName))
            {
                using (var sr = new StreamReader(stream))
                {
                    this.Settings =
                        DocFxIssuesSettings.FromContent(
                            sr.ReadToEnd(),
                            docRootPath);
                }
            }

            this.PrcaSettings =
                new ReportIssuesToPullRequestSettings(@"c:\Source\Cake.Prca");
        }
Ejemplo n.º 12
0
            public void Should_Read_File_From_Disk()
            {
                var fileName = System.IO.Path.GetTempFileName();

                try
                {
                    // Given
                    string expected;
                    using (var ms = new MemoryStream())
                        using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Prca.Issues.DocFx.Tests.Testfiles.docfx.json"))
                        {
                            stream.CopyTo(ms);
                            var data = ms.ToArray();

                            using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                            {
                                file.Write(data, 0, data.Length);
                            }

                            expected = ConvertFromUtf8(data);
                        }

                    // When
                    var settings =
                        DocFxIssuesSettings.FromFilePath(fileName, @"c:\Source\Cake.Prca\docs");

                    // Then
                    settings.LogFileContent.ShouldBe(expected);
                }
                finally
                {
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }
                }
            }