-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRouteResultTests.cs
More file actions
57 lines (45 loc) · 1.62 KB
/
RouteResultTests.cs
File metadata and controls
57 lines (45 loc) · 1.62 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
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using NUnit.Framework;
using Microsoft.AspNetCore.Mvc.Testing;
using System.Threading.Tasks;
using Newtonsoft.Json;
using NUnit.Framework.Internal;
using ProductsWithRouting;
namespace ProdutcsWithRoutingTests
{
public class RouteResultTests
{
private WebApplicationFactory<ProductsWithRouting.Startup> _factory;
private HttpClient _client;
[OneTimeSetUp]
public void OneTimeSetup()
{
_factory = new WebApplicationFactory<ProductsWithRouting.Startup>();
_client = _factory.CreateClient();
}
//[Test]
public async Task Test1()
{
// Arrange & Act
var response = await _client.GetAsync("http://localhost/Users/Index");
// Assert
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
var body = await response.Content.ReadAsStringAsync();
Assert.IsTrue(body.Contains("Edit"));
Assert.IsTrue(body.Contains("Details"));
Assert.IsTrue(body.Contains("Details"));
Assert.IsTrue(body.Contains("Create New"));
}
[TestCase("http://localhost/Users/Index")]
[TestCase("http://localhost/Users/Index/dfer")]
public async Task IndexUsersShouldBeUnauthorized(string url)
{
// Arrange & Act
var response = await _client.GetAsync(url);
// Assert
Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode);
}
}
}