• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

f2calv / CasCap.Common / 13300409113

13 Feb 2025 04:26AM UTC coverage: 0.334% (-0.03%) from 0.362%
13300409113

push

github

web-flow
F2calv/2025 02 updates (#215)

* logging

* tidy

* consolidate and rework IPAFValue and related objects + midpoint calc

* lots more tidynig

* fixed one more PAF test with Array2DConverter

* nuget

* big IGI tidy-up, still loads more to do

* PostAsync to HttpMessageRequest/Response

* nuget updates

* tidy SendAsync and fix tests

* nuget updates

* lint fixes

* tidy

0 of 336 branches covered (0.0%)

Branch coverage included in aggregate %.

0 of 79 new or added lines in 5 files covered. (0.0%)

4 existing lines in 3 files now uncovered.

3 of 561 relevant lines covered (0.53%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/CasCap.Common.Net/Extensions/NetHelpers.cs
1
namespace CasCap.Common.Extensions;
2

3
public static class NetHelpers
4
{
5
    public static string? TryGetValue(this HttpResponseHeaders headers, string name)
6
    {
7
        var headerValues = headers.GetValues(name);
×
8
        return headerValues.FirstOrDefault();
×
9
    }
10

11
    public static string ToQueryString(this NameValueCollection nvc)
12
    {
13
        var array = (from key in nvc.AllKeys
×
14
                     from value in nvc.GetValues(key)!
×
15
                     select $"{WebUtility.UrlEncode(key)}={WebUtility.UrlEncode(value)}")
×
16
                    .ToArray();
×
17
        return "?" + string.Join("&", array);
×
18
    }
19

20
    /// <summary>
21
    /// Adds all members of the name/value collection to the headers, if header name already exists the value is overwritten.
22
    /// </summary>
23
    public static void AddOrOverwrite(this HttpRequestHeaders headers, List<(string name, string value)>? additionalHeaders)
24
    {
NEW
25
        if (!additionalHeaders.IsNullOrEmpty())
×
NEW
26
            foreach (var header in additionalHeaders!)
×
NEW
27
                headers.AddOrOverwrite(header.name, header.value);
×
UNCOV
28
    }
×
29

30
    /// <inheritdoc cref="AddOrOverwrite(HttpRequestHeaders, List{ValueTuple{string, string}}?)"/>
31
    public static void AddOrOverwrite(this HttpRequestHeaders headers, Dictionary<string,string>? additionalHeaders)
32
    {
NEW
33
        if (!additionalHeaders.IsNullOrEmpty())
×
NEW
34
            foreach (var header in additionalHeaders!)
×
NEW
35
                headers.AddOrOverwrite(header.Key, header.Value);
×
NEW
36
    }
×
37

38
    /// <summary>
39
    /// Adds a name/value to the headers, if header name already exists the value is overwritten.
40
    /// </summary>
41
    public static void AddOrOverwrite(this HttpRequestHeaders headers, string name, string value)
42
    {
NEW
43
        if (headers.TryGetValues(name, out var _))
×
NEW
44
            headers.Remove(name);
×
NEW
45
        headers.Add(name, value);
×
NEW
46
    }
×
47

48
    //public static async Task<T?> ReadAsJsonAsync<T>(this HttpContent content)//for .NET Standard compatibility
49
    //{
50
    //    var json = await content.ReadAsStringAsync().ConfigureAwait(false);
51
    //    T? value = json.FromJson<T>();
52
    //    return value;
53
    //}
54

55
    //public static async Task<T> ReadAsJsonAsyncS<T>(this HttpContent content)//for .NET Standard compatibility
56
    //{
57
    //    var stream = await content.ReadAsStreamAsync().ConfigureAwait(false);
58
    //    T value = stream.FromJSON<T>();
59
    //    return value;
60
    //}
61

62
    //public static Task<HttpResponseMessage> PostAsJsonAsync<T>(this HttpClient httpClient, string url, T obj)//for .NET Standard compatibility
63
    //{
64
    //    var json = obj!.ToJson();
65
    //    var content = new StringContent(json, Encoding.UTF8, "application/json");
66
    //    return httpClient.PostAsync(url, content);
67
    //}
68

69
    //public static Task<HttpResponseMessage> PutAsJsonAsync<T>(this HttpClient httpClient, string url, T obj)//for .NET Standard compatibility
70
    //{
71
    //    return httpClient.PostAsJsonAsync<T>(url, obj);
72
    //}
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc