Skip to content

Commit 5bde7f0

Browse files
author
Chris Santero
committed
add test for filtering
1 parent dd907d9 commit 5bde7f0

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

JSONAPI.TodoMVC.API.Tests/Acceptance/AcceptanceTests.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ public async Task Get()
3838
}
3939
}
4040

41+
[TestMethod]
42+
[DeploymentItem(@"Data\Todo.csv", "Data")]
43+
public async Task GetWithFilter()
44+
{
45+
using (var effortConnection = TestHelpers.GetEffortConnection("Data"))
46+
{
47+
using (var server = TestServer.Create(app =>
48+
{
49+
var startup = new Startup(context => new TodoMvcContext(effortConnection, false));
50+
startup.Configuration(app);
51+
}))
52+
{
53+
var response = await server.CreateRequest("http://localhost/todos?isCompleted=true").GetAsync();
54+
response.StatusCode.Should().Be(HttpStatusCode.OK);
55+
var responseContent = await response.Content.ReadAsStringAsync();
56+
57+
var expected =
58+
JsonHelpers.MinifyJson(
59+
TestHelpers.ReadEmbeddedFile(@"Acceptance\Fixtures\GetWithFilterResponse.json"));
60+
responseContent.Should().Be(expected);
61+
}
62+
}
63+
}
64+
4165
[TestMethod]
4266
[DeploymentItem(@"Data\Todo.csv", "Data")]
4367
public async Task GetById()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"todos": [
3+
{
4+
"id": "2",
5+
"text": "Do the laundry",
6+
"isCompleted": true
7+
}
8+
]
9+
}

JSONAPI.TodoMVC.API.Tests/JSONAPI.TodoMVC.API.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
<EmbeddedResource Include="Acceptance\Fixtures\PostResponse.json" />
128128
<EmbeddedResource Include="Acceptance\Fixtures\PutRequest.json" />
129129
<EmbeddedResource Include="Acceptance\Fixtures\PutResponse.json" />
130+
<EmbeddedResource Include="Acceptance\Fixtures\GetWithFilterResponse.json" />
130131
<None Include="app.config" />
131132
<None Include="Data\Todo.csv">
132133
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

0 commit comments

Comments
 (0)