-
Notifications
You must be signed in to change notification settings - Fork 23
/
PizzaVotesTests.cs
90 lines (75 loc) · 2.28 KB
/
PizzaVotesTests.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
90
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Xunit;
using backend;
namespace PizzaVotes.Tests
{
public class PizzaVotesTests : IClassFixture<TestFixture<Startup>>
{
private HttpClient Client;
public PizzaVotesTests(TestFixture<Startup> fixture)
{
Client = fixture.Client;
}
[Fact]
public async Task TestGetAllVotesAsync()
{
// Arrange
var request = "/api/pizzavotes";
// Act
var response = await Client.GetAsync(request);
// Assert
response.EnsureSuccessStatusCode();
}
[Fact]
public async Task TestGetUserVotesAsync()
{
// Arrange
var request = "/api/pizzavotes/mihail.gaberov@gmail.com";
// Act
var response = await Client.GetAsync(request);
// Assert
Assert.Equal("Unauthorized", response.StatusCode.ToString());
}
[Fact]
public async Task TestPostVoteAsync()
{
// Arrange
var request = new
{
Url = "/api/pizzavotes",
Body = new
{
Id = "mihail.gaberov1@gmail.com",
Value = 1,
DateTime = DateTime.Now
}
};
// Act
var response = await Client.PostAsync(request.Url, ContentHelper.GetStringContent(request.Body));
var value = await response.Content.ReadAsStringAsync();
// Assert
Assert.Equal("Unauthorized", response.StatusCode.ToString());
}
[Fact]
public async Task TestPutUserVoteAsync()
{
// Arrange
var request = new
{
Url = "/api/pizzavotes/mihail.gaberov@gmail.com",
Body = new
{
Value = 2,
DateTime = DateTime.Now
}
};
// Act
var response = await Client.PutAsync(request.Url, ContentHelper.GetStringContent(request.Body));
// Assert
Assert.Equal("Unauthorized", response.StatusCode.ToString());
}
}
}