< Summary

Information
Class: Api.Extensions.PagedResponseUtil
Assembly: Api
File(s): /home/runner/work/Northwind-Api/Northwind-Api/src/Api/Extensions/PagedResponseUtil.cs
Line coverage
78%
Covered lines: 11
Uncovered lines: 3
Coverable lines: 14
Total lines: 25
Line coverage: 78.5%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetBaseUrl(...)100%22100%
BuildPagedUrl(...)100%11100%
CalculateTotalPages(...)100%210%

File(s)

/home/runner/work/Northwind-Api/Northwind-Api/src/Api/Extensions/PagedResponseUtil.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2
 3[assembly: InternalsVisibleTo("UnitTests")]
 4namespace Api.Extensions;
 5
 6internal static class PagedResponseUtil {
 27  internal static string GetBaseUrl(this HttpRequest? request) {
 38    if (request == null) {
 19      return string.Empty;
 10    }
 111    return $"{request.Scheme}://{request.Host}{request.Path}";
 212  }
 13
 114  internal static Uri BuildPagedUrl(this string baseUrl, int pageNumber, int pageSize) {
 115    var uriBuilder = new UriBuilder(baseUrl) {
 116      Query = $"pageNumber={pageNumber}&pageSize={pageSize}",
 117    };
 118    return uriBuilder.Uri;
 119  }
 20
 21  //TODO wierd extension (FIX?)
 022  internal static int CalculateTotalPages(this int totalRecords, int pageSize) {
 023    return (int)Math.Ceiling((double)totalRecords / pageSize);
 024  }
 25}