public async Task Post_with_empty_id() { using (var effortConnection = GetEffortConnection()) { var response = await SubmitPost(effortConnection, "posts", @"Fixtures\CreatingResources\Requests\Post_with_empty_id_Request.json"); await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\Post_with_empty_id_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"); } } }
public async Task Post_with_client_provided_id() { using (var effortConnection = GetEffortConnection()) { var response = await SubmitPost(effortConnection, "posts", @"Fixtures\CreatingResources\Requests\Post_with_client_provided_id_Request.json"); await AssertResponseContent(response, @"Fixtures\CreatingResources\Responses\Post_with_client_provided_id_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 == "205"); actualPost.Id.Should().Be("205"); actualPost.Title.Should().Be("Added post"); actualPost.Content.Should().Be("Added post content"); actualPost.Created.Should().Be(new DateTimeOffset(2015, 03, 11, 04, 31, 0, new TimeSpan(0))); actualPost.AuthorId.Should().Be("401"); } } }
public async Task Patch_with_unknown_attribute() { using (var effortConnection = GetEffortConnection()) { var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\Patch_with_unknown_attribute_Request.json"); await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\Patch_with_unknown_attribute_Response.json", HttpStatusCode.OK); using (var dbContext = new TestDbContext(effortConnection, false)) { var allPosts = dbContext.Posts.Include(p => p.Tags).ToArray(); allPosts.Length.Should().Be(4); var actualPost = allPosts.First(t => t.Id == "202"); actualPost.Id.Should().Be("202"); actualPost.Title.Should().Be("New post title"); actualPost.Content.Should().Be("Post 2 content"); actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); actualPost.AuthorId.Should().Be("401"); actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); } } }
public async Task PatchWithToManyLinkageObjectMissingType() { using (var effortConnection = GetEffortConnection()) { var response = await SubmitPatch(effortConnection, "posts/202", @"Fixtures\UpdatingResources\Requests\PatchWithToManyLinkageObjectMissingTypeRequest.json"); await AssertResponseContent(response, @"Fixtures\UpdatingResources\Responses\PatchWithToManyLinkageObjectMissingTypeResponse.json", HttpStatusCode.BadRequest, true); using (var dbContext = new TestDbContext(effortConnection, false)) { var allPosts = dbContext.Posts.ToArray(); allPosts.Length.Should().Be(4); var actualPost = allPosts.First(t => t.Id == "202"); actualPost.Id.Should().Be("202"); actualPost.Title.Should().Be("Post 2"); actualPost.Content.Should().Be("Post 2 content"); actualPost.Created.Should().Be(new DateTimeOffset(2015, 02, 05, 08, 10, 0, new TimeSpan(0))); actualPost.AuthorId.Should().Be("401"); actualPost.Tags.Select(t => t.Id).Should().BeEquivalentTo("302", "303"); } } }