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
Expand Up @@ -112,5 +112,34 @@ public async Task Post_with_empty_id()
}
}
}


[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 Post_with_empty_id_and_include()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitPost(effortConnection, "posts?include=author", @"Fixtures\CreatingResources\Requests\Post_with_empty_id_Request.json");

await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\Post_with_empty_id_and_include_author_Response.json", HttpStatusCode.OK);

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allPosts = dbContext.Posts.ToArray();
allPosts.Length.Should().Be(5);
var actualPost = allPosts.First(t => t.Id == "230");
actualPost.Id.Should().Be("230");
actualPost.Title.Should().Be("New post");
actualPost.Content.Should().Be("The server generated my ID");
actualPost.Created.Should().Be(new DateTimeOffset(2015, 04, 13, 12, 09, 0, new TimeSpan(0, 3, 0, 0)));
actualPost.AuthorId.Should().Be("401");
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ public async Task Get_related_to_many()
}
}


[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 Get_related_to_many_included()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitGet(effortConnection, "posts/201/comments?include=author");

await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_related_to_many_include_response.json", HttpStatusCode.OK);
}
}

[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Data")]
[DeploymentItem(@"Data\Post.csv", @"Data")]
Expand All @@ -115,6 +132,23 @@ public async Task Get_related_to_one()
}
}


[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 Get_included_to_one()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitGet(effortConnection, "posts/201?include=author");

await AssertResponseContent(response, @"Fixtures\FetchingResources\Get_included_to_one_response.json", HttpStatusCode.OK);
}
}

[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Data")]
[DeploymentItem(@"Data\Post.csv", @"Data")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"data": {
"type": "posts",
"id": "230",
"attributes": {
"content": "The server generated my ID",
"created": "2015-04-13T09:09:00.0000000+00:00",
"title": "New post"
},
"relationships": {
"author": {
"links": {
"self": "https://www.example.com/posts/230/relationships/author",
"related": "https://www.example.com/posts/230/author"
},
"data": {
"type": "users",
"id": "401"
}
},
"comments": {
"links": {
"self": "https://www.example.com/posts/230/relationships/comments",
"related": "https://www.example.com/posts/230/comments"
}
},
"tags": {
"links": {
"self": "https://www.example.com/posts/230/relationships/tags",
"related": "https://www.example.com/posts/230/tags"
}
}
}
},
"included": [
{
"type": "users",
"id": "401",
"attributes": {
"first-name": "Alice",
"last-name": "Smith"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/401/relationships/comments",
"related": "https://www.example.com/users/401/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/401/relationships/posts",
"related": "https://www.example.com/users/401/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/401/relationships/user-groups",
"related": "https://www.example.com/users/401/user-groups"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"data": {
"type": "posts",
"id": "201",
"attributes": {
"content": "Post 1 content",
"created": "2015-01-31T14:00:00.0000000+00:00",
"title": "Post 1"
},
"relationships": {
"author": {
"links": {
"self": "https://www.example.com/posts/201/relationships/author",
"related": "https://www.example.com/posts/201/author"
},
"data": {
"type": "users",
"id": "401"
}
},
"comments": {
"links": {
"self": "https://www.example.com/posts/201/relationships/comments",
"related": "https://www.example.com/posts/201/comments"
}
},
"tags": {
"links": {
"self": "https://www.example.com/posts/201/relationships/tags",
"related": "https://www.example.com/posts/201/tags"
}
}
}
},
"included": [
{
"type": "users",
"id": "401",
"attributes": {
"first-name": "Alice",
"last-name": "Smith"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/401/relationships/comments",
"related": "https://www.example.com/users/401/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/401/relationships/posts",
"related": "https://www.example.com/users/401/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/401/relationships/user-groups",
"related": "https://www.example.com/users/401/user-groups"
}
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"data": [
{
"type": "comments",
"id": "101",
"attributes": {
"created": "2015-01-31T14:30:00.0000000+00:00",
"text": "Comment 1"
},
"relationships": {
"author": {
"links": {
"self": "https://www.example.com/comments/101/relationships/author",
"related": "https://www.example.com/comments/101/author"
},
"data": {
"type": "users",
"id": "403"
}
},
"post": {
"links": {
"self": "https://www.example.com/comments/101/relationships/post",
"related": "https://www.example.com/comments/101/post"
}
}
}
},
{
"type": "comments",
"id": "102",
"attributes": {
"created": "2015-01-31T14:35:00.0000000+00:00",
"text": "Comment 2"
},
"relationships": {
"author": {
"links": {
"self": "https://www.example.com/comments/102/relationships/author",
"related": "https://www.example.com/comments/102/author"
},
"data": {
"type": "users",
"id": "402"
}
},
"post": {
"links": {
"self": "https://www.example.com/comments/102/relationships/post",
"related": "https://www.example.com/comments/102/post"
}
}
}
},
{
"type": "comments",
"id": "103",
"attributes": {
"created": "2015-01-31T14:41:00.0000000+00:00",
"text": "Comment 3"
},
"relationships": {
"author": {
"links": {
"self": "https://www.example.com/comments/103/relationships/author",
"related": "https://www.example.com/comments/103/author"
},
"data": {
"type": "users",
"id": "403"
}
},
"post": {
"links": {
"self": "https://www.example.com/comments/103/relationships/post",
"related": "https://www.example.com/comments/103/post"
}
}
}
}
],
"included": [
{
"type": "users",
"id": "403",
"attributes": {
"first-name": "Charlie",
"last-name": "Michaels"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/403/relationships/comments",
"related": "https://www.example.com/users/403/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/403/relationships/posts",
"related": "https://www.example.com/users/403/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/403/relationships/user-groups",
"related": "https://www.example.com/users/403/user-groups"
}
}
}
},
{
"type": "users",
"id": "402",
"attributes": {
"first-name": "Bob",
"last-name": "Jones"
},
"relationships": {
"comments": {
"links": {
"self": "https://www.example.com/users/402/relationships/comments",
"related": "https://www.example.com/users/402/comments"
}
},
"posts": {
"links": {
"self": "https://www.example.com/users/402/relationships/posts",
"related": "https://www.example.com/users/402/posts"
}
},
"user-groups": {
"links": {
"self": "https://www.example.com/users/402/relationships/user-groups",
"related": "https://www.example.com/users/402/user-groups"
}
}
}
}
]
}
Loading