-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathFunctionalTests.cs
More file actions
33 lines (26 loc) · 993 Bytes
/
FunctionalTests.cs
File metadata and controls
33 lines (26 loc) · 993 Bytes
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
using System.Net;
namespace EssentialCSharp.Web.Tests;
public class FunctionalTests
{
[Theory]
[InlineData("/")]
[InlineData("/hello-world")]
[InlineData("/hello-world#hello-world")]
[InlineData("/guidelines")]
[InlineData("/healthz")]
public async Task WhenTheApplicationStarts_ItCanLoadLoadPages(string relativeUrl)
{
using WebApplicationFactory factory = new();
HttpClient client = factory.CreateClient();
using HttpResponseMessage response = await client.GetAsync(relativeUrl);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
[Fact]
public async Task WhenTheApplicationStarts_NonExistingPage_GivesCorrectStatusCode()
{
using WebApplicationFactory factory = new();
HttpClient client = factory.CreateClient();
using HttpResponseMessage response = await client.GetAsync("/non-existing-page1234");
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
}