Skip to content

Commit 751f768

Browse files
committed
test(acceptance): can use non json-api controllers
1 parent f9564f5 commit 751f768

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace JsonApiDotNetCoreExample.Controllers
4+
{
5+
[Route("[controller]")]
6+
public class TestValuesController : Controller
7+
{
8+
[HttpGet]
9+
public IActionResult Get()
10+
{
11+
var result = new string[] { "value" };
12+
return Ok(result);
13+
}
14+
}
15+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Net;
2+
using System.Net.Http;
3+
using System.Threading.Tasks;
4+
using Microsoft.AspNetCore.Hosting;
5+
using Microsoft.AspNetCore.TestHost;
6+
using Xunit;
7+
using JsonApiDotNetCoreExample;
8+
9+
namespace JsonApiDotNetCoreExampleTests.Acceptance.Extensibility
10+
{
11+
[Collection("WebHostCollection")]
12+
public class CustomControllerTests
13+
{
14+
[Fact]
15+
public async Task NonJsonApiControllers_DoNotUse_Dasherized_Routes()
16+
{
17+
// arrange
18+
var builder = new WebHostBuilder()
19+
.UseStartup<Startup>();
20+
var httpMethod = new HttpMethod("GET");
21+
var route = $"testValues";
22+
23+
var server = new TestServer(builder);
24+
var client = server.CreateClient();
25+
var request = new HttpRequestMessage(httpMethod, route);
26+
27+
// act
28+
var response = await client.SendAsync(request);
29+
30+
// assert
31+
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)