Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"meta": {
"total-pages": 2,
"total-count": 4
},
"data": [
{
"type": "posts",
"id": "203",
"attributes": {
"content": "Post 3 content",
"created": "2015-02-07T11:11:00.0000000+00:00",
"title": "Post 3"
},
"relationships": {
"author": {
"links": {
"self": "https://www.example.com/posts/203/relationships/author",
"related": "https://www.example.com/posts/203/author"
}
},
"comments": {
"links": {
"self": "https://www.example.com/posts/203/relationships/comments",
"related": "https://www.example.com/posts/203/comments"
}
},
"tags": {
"links": {
"self": "https://www.example.com/posts/203/relationships/tags",
"related": "https://www.example.com/posts/203/tags"
}
}
}
},
{
"type": "posts",
"id": "204",
"attributes": {
"content": "Post 4 content",
"created": "2015-02-08T06:59:00.0000000+00:00",
"title": "Post 4"
},
"relationships": {
"author": {
"links": {
"self": "https://www.example.com/posts/204/relationships/author",
"related": "https://www.example.com/posts/204/author"
}
},
"comments": {
"links": {
"self": "https://www.example.com/posts/204/relationships/comments",
"related": "https://www.example.com/posts/204/comments"
}
},
"tags": {
"links": {
"self": "https://www.example.com/posts/204/relationships/tags",
"related": "https://www.example.com/posts/204/tags"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"meta": {
"total-pages": 2,
"total-count": 3
},
"data": [
{
"type": "users",
"id": "410",
"attributes": {
"first-name": "Sally",
"last-name": "Burns"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/410/relationships/comments",
"related": "https://www.example.com/users/410/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/410/relationships/posts",
"related": "https://www.example.com/users/410/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/410/relationships/user-groups",
"related": "https://www.example.com/users/410/user-groups"
}
}
}
},
{
"type": "users",
"id": "406",
"attributes": {
"first-name": "Ed",
"last-name": "Burns"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/406/relationships/comments",
"related": "https://www.example.com/users/406/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/406/relationships/posts",
"related": "https://www.example.com/users/406/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/406/relationships/user-groups",
"related": "https://www.example.com/users/406/user-groups"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"meta": {
"total-pages": 2,
"total-count": 3
},
"data": [
{
"type": "users",
"id": "409",
"attributes": {
"first-name": "Charlie",
"last-name": "Burns"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/409/relationships/comments",
"related": "https://www.example.com/users/409/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/409/relationships/posts",
"related": "https://www.example.com/users/409/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/409/relationships/user-groups",
"related": "https://www.example.com/users/409/user-groups"
}
}
}
},
{
"type": "users",
"id": "406",
"attributes": {
"first-name": "Ed",
"last-name": "Burns"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/406/relationships/comments",
"related": "https://www.example.com/users/406/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/406/relationships/posts",
"related": "https://www.example.com/users/406/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/406/relationships/user-groups",
"related": "https://www.example.com/users/406/user-groups"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"meta": {
"total-pages": 3,
"total-count": 3
},
"data": [
{
"type": "users",
"id": "409",
"attributes": {
"first-name": "Charlie",
"last-name": "Burns"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/409/relationships/comments",
"related": "https://www.example.com/users/409/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/409/relationships/posts",
"related": "https://www.example.com/users/409/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/409/relationships/user-groups",
"related": "https://www.example.com/users/409/user-groups"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Compile Include="CreatingResourcesTests.cs" />
<Compile Include="DeletingResourcesTests.cs" />
<Compile Include="ErrorsTests.cs" />
<Compile Include="PaginationTests.cs" />
<Compile Include="FetchingResourcesTests.cs" />
<Compile Include="HeterogeneousTests.cs" />
<Compile Include="MappedTests.cs" />
Expand Down Expand Up @@ -275,8 +276,13 @@
<EmbeddedResource Include="Fixtures\FetchingResources\Get_related_to_many_include_response.json" />
<EmbeddedResource Include="Fixtures\CreatingResources\Responses\Post_with_empty_id_and_include_author_Response.json" />
<EmbeddedResource Include="Fixtures\UpdatingResources\Responses\PatchWithAttributeUpdateWithIncludeResponse.json" />
<EmbeddedResource Include="Fixtures\Pagination\GetAllResponsePaged-2-2.json" />
<EmbeddedResource Include="Fixtures\Pagination\GetFilterPaged-2-1.json" />
<EmbeddedResource Include="Fixtures\Pagination\GetFilterPaged-1-2-sorted.json" />
<EmbeddedResource Include="Fixtures\Pagination\GetFilterPaged-1-2-sorted-desc.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System.Net;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests
{
[TestClass]
public class PaginationTests : AcceptanceTestsBase
{
[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Data")]
[DeploymentItem(@"Data\Post.csv", @"Data")]
[DeploymentItem(@"Data\PostTagLink.csv", @"Data")]
[DeploymentItem(@"Data\Tag.csv", @"Data")]
[DeploymentItem(@"Data\User.csv", @"Data")]
public async Task GetPage2Post2()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitGet(effortConnection, "posts?page[number]=1&page[size]=2");

await AssertResponseContent(response, @"Fixtures\Pagination\GetAllResponsePaged-2-2.json", HttpStatusCode.OK);
}
}

[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Data")]
[DeploymentItem(@"Data\Post.csv", @"Data")]
[DeploymentItem(@"Data\PostTagLink.csv", @"Data")]
[DeploymentItem(@"Data\Tag.csv", @"Data")]
[DeploymentItem(@"Data\User.csv", @"Data")]
public async Task GetWithFilter()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=1&page[size]=1");

await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-2-1.json", HttpStatusCode.OK);
}
}


[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Data")]
[DeploymentItem(@"Data\Post.csv", @"Data")]
[DeploymentItem(@"Data\PostTagLink.csv", @"Data")]
[DeploymentItem(@"Data\Tag.csv", @"Data")]
[DeploymentItem(@"Data\User.csv", @"Data")]
public async Task GetWithFilterSortedAscTest()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=0&page[size]=2&sort=first-name");

await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-1-2-sorted.json", HttpStatusCode.OK);
}
}


[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Data")]
[DeploymentItem(@"Data\Post.csv", @"Data")]
[DeploymentItem(@"Data\PostTagLink.csv", @"Data")]
[DeploymentItem(@"Data\Tag.csv", @"Data")]
[DeploymentItem(@"Data\User.csv", @"Data")]
public async Task GetWithFilterSortedDescTest()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitGet(effortConnection, "users?filter[last-name]=Burns&page[number]=0&page[size]=2&sort=-first-name");

await AssertResponseContent(response, @"Fixtures\Pagination\GetFilterPaged-1-2-sorted-desc.json", HttpStatusCode.OK);
}
}

}
}
4 changes: 4 additions & 0 deletions JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using JSONAPI.EntityFramework.Configuration;
using Owin;
using System.Collections.Generic;
using JSONAPI.Documents.Builders;
using JSONAPI.EntityFramework.Documents.Builders;

namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp
{
Expand Down Expand Up @@ -112,6 +114,8 @@ internal JsonApiHttpAutofacConfigurator BuildAutofacConfigurator(IAppBuilder app
builder.RegisterType<CustomEntityFrameworkResourceObjectMaterializer>()
.As<IEntityFrameworkResourceObjectMaterializer>();
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterType<EntityFrameworkQueryableResourceCollectionDocumentBuilder>().As<IQueryableResourceCollectionDocumentBuilder>();

});
configurator.OnApplicationLifetimeScopeBegun(applicationLifetimeScope =>
{
Expand Down
Loading