forked from linguanostra/GoogleMapsAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebRequestUtilityTestsExtensions.cs
More file actions
76 lines (60 loc) · 2.76 KB
/
Copy pathWebRequestUtilityTestsExtensions.cs
File metadata and controls
76 lines (60 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using GoogleMapsAPI.NET.Requests;
using GoogleMapsAPI.NET.Requests.Interfaces;
using Rhino.Mocks;
using Rhino.Mocks.Interfaces;
namespace GoogleMapsAPI.NET.Tests.API.Extensions
{
/// <summary>
/// Web request utility tests extensions
/// </summary>
public static class WebRequestUtilityTestsExtensions
{
#region Extension methods
/// <summary>
/// Assert the Get method for the web request utility was called with given url
/// </summary>
/// <param name="webRequestUtil">Web request utility</param>
/// <param name="url">Url</param>
/// <param name="useCredentials">Use credentials from client</param>
public static void AssertGetWasCalledWithurl(this IWebRequestUtility webRequestUtil, string url, bool useCredentials = true)
{
// Normalize url with credentials, if required
var normalizedUrl = useCredentials ? webRequestUtil.AppendCredentialsTourl(url) : url;
// Assertion
webRequestUtil.AssertWasCalled(utility =>
utility.Get(
Arg<string>.Is.Equal(normalizedUrl),
Arg<RequestConfig>.Is.Anything));
}
/// <summary>
/// Assert the Get method for the web request utility was called once with given url
/// </summary>
/// <param name="webRequestUtil">Web request utility</param>
/// <param name="url">Url</param>
/// <param name="useCredentials">Use credentials from client</param>
public static void AssertGetWasCalledOnceWithurl(this IWebRequestUtility webRequestUtil, string url, bool useCredentials = true)
{
webRequestUtil.AssertGetWasCalledWithurl(url, options => options.Repeat.Once(), useCredentials);
}
/// <summary>
/// Assert the Get method for the web request utility was called with given url
/// </summary>
/// <param name="webRequestUtil">Web request utility</param>
/// <param name="url">Url</param>
/// <param name="options">Options</param>
/// <param name="useCredentials">Use credentials from client</param>
public static void AssertGetWasCalledWithurl(this IWebRequestUtility webRequestUtil, string url, Action<IMethodOptions<object>> options, bool useCredentials = true)
{
// Normalize url with credentials, if required
var normalizedUrl = useCredentials ? webRequestUtil.AppendCredentialsTourl(url) : url;
// Assertion
webRequestUtil.AssertWasCalled(utility =>
utility.Get(
Arg<string>.Is.Equal(normalizedUrl),
Arg<RequestConfig>.Is.Anything),
options);
}
#endregion
}
}