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

loresoft / FluentRest / 7318593291

25 Dec 2023 02:55AM UTC coverage: 52.206%. Remained the same
7318593291

Pull #158

github

web-flow
Merge 38e3e6116 into 7b58509ff
Pull Request #158: Bump xunit.runner.visualstudio from 2.5.4 to 2.5.6

182 of 438 branches covered (0.0%)

Branch coverage included in aggregate %.

516 of 899 relevant lines covered (57.4%)

86.76 hits per line

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

33.33
/src/FluentRest/RequestBuilder.cs
1
using System;
2
using System.Net.Http;
3
using System.Threading;
4

5
namespace FluentRest;
6

7
/// <summary>
8
/// A fluent request builder.
9
/// </summary>
10
/// <typeparam name="TBuilder">The type of the builder.</typeparam>
11
public abstract class RequestBuilder<TBuilder>
12
    where TBuilder : RequestBuilder<TBuilder>
13
{
14
    /// <summary>
15
    /// Gets the fluent HTTP request being built.
16
    /// </summary>
17
    /// <value>
18
    /// The fluent HTTP request being built.
19
    /// </value>
20
    public HttpRequestMessage RequestMessage { get; }
21

22
    /// <summary>
23
    /// Initializes a new instance of the <see cref="RequestBuilder{TBuilder}"/> class.
24
    /// </summary>
25
    /// <param name="requestMessage">The fluent HTTP request being built.</param>
26
    protected RequestBuilder(HttpRequestMessage requestMessage)
27
    {
28
        RequestMessage = requestMessage;
213✔
29
    }
213✔
30

31
    /// <summary>
32
    /// Sets the cancellation token to cancel the request operation.
33
    /// </summary>
34
    /// <param name="cancellationToken">The cancellation token.</param>
35
    /// <returns>A fluent request builder.</returns>
36
    public TBuilder CancellationToken(CancellationToken cancellationToken)
37
    {
38
        RequestMessage.SetCancellationToken(cancellationToken);
6✔
39
        return this as TBuilder;
6✔
40
    }
41

42
    /// <summary>
43
    /// Sets when the operation should complete (as soon as a response is available or after reading the whole response content).
44
    /// </summary>
45
    /// <param name="completionOption">When the operation should complete.</param>
46
    /// <returns>A fluent request builder.</returns>
47
    public TBuilder CompletionOption(HttpCompletionOption completionOption)
48
    {
49
        RequestMessage.SetCompletionOption(completionOption);
×
50
        return this as TBuilder;
×
51
    }
52

53

54
    /// <summary>
55
    /// Sets a state value on the request.
56
    /// </summary>
57
    /// <param name="key">The state key.</param>
58
    /// <param name="value">The state value.</param>
59
    /// <returns>A fluent request builder.</returns>
60
    /// <exception cref="ArgumentException">Argument is null or empty</exception>
61
    public TBuilder State(string key, object value)
62
    {
63
        if (string.IsNullOrEmpty(key))
×
64
            throw new ArgumentException("Argument is null or empty", nameof(key));
×
65

66
        RequestMessage.Properties[key] = value;
×
67
        return this as TBuilder;
×
68
    }
69
}
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