Exemplo n.º 1
0
        public async Task ShouldGetFileInformation()
        {
            // Given
            var source = @"
            <h2 id=""blob-path"" class=""breadcrumb flex-auto min-width-0 text-normal mx-0 mx-md-3 width-full width-md-auto flex-order-1 flex-md-order-none mt-3 mt-md-0"">
            <span class=""js-repo-root text-bold""><span class=""js-path-segment d-inline-block wb-break-all""><a data-pjax=""true"" href=""/paulojsilva/web-scraping-nolayer""><span>web-scraping-nolayer</span></a></span></span><span class=""separator"">/</span><strong class=""final-path"">Startup.cs</strong>
            </h2>
            <div class=""Box-header py-2 d-flex flex-column flex-shrink-0 flex-md-row flex-md-items-center"">
              <div class=""text-mono f6 flex-auto pr-3 flex-order-2 flex-md-order-1 mt-2 mt-md-0"">

                  76 lines (63 sloc)
                  <span class=""file-info-divider""></span>
                2.33 KB
              </div>
            </div>";

            var document = await context.OpenAsync(req => req.Content(source));

            var parser = new GitHubParser(document, "github.com");

            // When
            var fileInformation = parser.GetFileInformation();

            // Then
            fileInformation.Bytes.Should().Be(2330);
            fileInformation.Lines.Should().Be(76);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get the filename and total (line, bytes)
 /// </summary>
 /// <param name="parser">Contain full DOM Elements (IDocument) and helpers to use it</param>
 protected virtual void GetSynthesizedFileInformation(GitHubParser parser) => this.temporaryFiles.Add(parser.GetFileInformation());