/
end_to_end.cs
89 lines (74 loc) · 2.03 KB
/
end_to_end.cs
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
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.Globalization;
using System.Net.Http.Headers;
using Alba;
using Shouldly;
using WolverineWebApi;
namespace Wolverine.Http.Tests;
public class end_to_end : IntegrationContext
{
public end_to_end(AppFixture fixture) : base(fixture)
{
}
[Fact]
public async Task retrieve_text_data()
{
var body = await Scenario(x =>
{
x.Get.Url("/hello");
x.StatusCodeShouldBeOk();
x.Header("content-type").SingleValueShouldEqual("text/plain");
});
(await body.ReadAsTextAsync()).ShouldBe("Hello");
}
[Fact]
public async Task retrieve_json_data()
{
var body = await Scenario(x =>
{
x.Get.Url("/results/static");
x.StatusCodeShouldBeOk();
x.Header("content-type").SingleValueShouldEqual("application/json; charset=utf-8");
});
var results = body.ReadAsJson<ArithmeticResults>();
results.Product.ShouldBe(4);
results.Sum.ShouldBe(3);
}
[Fact]
public async Task use_string_route_argument()
{
var body = await Scenario(x =>
{
x.Get.Url("/name/Lebron");
x.Header("content-type").SingleValueShouldEqual("text/plain");
});
body.ReadAsText().ShouldBe("Name is Lebron");
}
[Fact]
public async Task use_enum_route_argument()
{
var body = await Scenario(x =>
{
x.Get.Url("/enum/west");
});
body.ReadAsText().ShouldBe("Direction is West");
}
[Fact]
public async Task use_int_route_argument_happy_path()
{
var body = await Scenario(x =>
{
x.Get.Url("/age/49");
x.Header("content-type").SingleValueShouldEqual("text/plain");
});
body.ReadAsText().ShouldBe("Age is 49");
}
[Fact]
public async Task use_int_route_argument_sad_path()
{
var body = await Scenario(x =>
{
x.Get.Url("/age/junk");
x.StatusCodeShouldBe(404);
});
}
}