forked from Code-Sharp/uHttpSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpMethodProviderCacheTests.cs
More file actions
65 lines (51 loc) · 1.59 KB
/
HttpMethodProviderCacheTests.cs
File metadata and controls
65 lines (51 loc) · 1.59 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
using NSubstitute;
using NUnit.Framework;
using Shouldly;
namespace uhttpsharp.Tests
{
public class HttpMethodProviderCacheTests
{
private const string MethodName = "Hello World";
private static IHttpMethodProvider GetTarget(IHttpMethodProvider child)
{
return new HttpMethodProviderCache(child);
}
[Test]
public void Should_Call_Child_With_Right_Parameters()
{
// Arrange
var mock = Substitute.For<IHttpMethodProvider>();
var target = GetTarget(mock);
// Act
target.Provide(MethodName);
// Assert
mock.Received(1).Provide(MethodName);
}
[Test]
public void Should_Return_Same_Child_Value()
{
// Arrange
const HttpMethods expectedMethod = HttpMethods.Post;
var mock = Substitute.For<IHttpMethodProvider>();
mock.Provide(MethodName).Returns(expectedMethod);
var target = GetTarget(mock);
// Act
var actual = target.Provide(MethodName);
// Assert
actual.ShouldBe(expectedMethod);
}
[Test]
public void Should_Cache_The_Value()
{
// Arrange
var mock = Substitute.For<IHttpMethodProvider>();
var target = GetTarget(mock);
// Act
target.Provide(MethodName);
target.Provide(MethodName);
target.Provide(MethodName);
// Assert
mock.Received(1).Provide(MethodName);
}
}
}