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 @@ -39,6 +39,52 @@ public async Task Post_with_client_provided_id()
}
}

[TestMethod]
[DeploymentItem(@"Data\PostID.csv", @"Data")]
public async Task PostID_with_client_provided_id()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitPost(effortConnection, "post-i-ds", @"Fixtures\CreatingResources\Requests\PostID_with_client_provided_id_Request.json");

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

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allPosts = dbContext.PostsID.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)));
}
}
}

[TestMethod]
[DeploymentItem(@"Data\PostLongId.csv", @"Data")]
public async Task PostLongId_with_client_provided_id()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitPost(effortConnection, "post-long-ids", @"Fixtures\CreatingResources\Requests\PostLongId_with_client_provided_id_Request.json");

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

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allPosts = dbContext.PostsLongId.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)));
}
}
}

[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,5 @@
ID,Title,Content,Created,AuthorId
"201","Post 1","Post 1 content","2015-01-31T14:00Z"
"202","Post 2","Post 2 content","2015-02-05T08:10Z"
"203","Post 3","Post 3 content","2015-02-07T11:11Z"
"204","Post 4","Post 4 content","2015-02-08T06:59Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Id,Title,Content,Created,AuthorId
201,"Post 1","Post 1 content","2015-01-31T14:00Z"
202,"Post 2","Post 2 content","2015-02-05T08:10Z"
203,"Post 3","Post 3 content","2015-02-07T11:11Z"
204,"Post 4","Post 4 content","2015-02-08T06:59Z"
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Tests
public class DeletingResourcesTests : AcceptanceTestsBase
{
[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Acceptance\Data")]
[DeploymentItem(@"Data\Post.csv", @"Acceptance\Data")]
[DeploymentItem(@"Data\PostTagLink.csv", @"Acceptance\Data")]
[DeploymentItem(@"Data\Tag.csv", @"Acceptance\Data")]
[DeploymentItem(@"Data\User.csv", @"Acceptance\Data")]
[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 Delete()
{
using (var effortConnection = GetEffortConnection())
Expand All @@ -28,10 +28,54 @@ public async Task Delete()

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allTodos = dbContext.Posts.ToArray();
allTodos.Length.Should().Be(3);
var actualTodo = allTodos.FirstOrDefault(t => t.Id == "203");
actualTodo.Should().BeNull();
var allPosts = dbContext.Posts.ToArray();
allPosts.Length.Should().Be(3);
var actualPosts = allPosts.FirstOrDefault(t => t.Id == "203");
actualPosts.Should().BeNull();
}
}
}

[TestMethod]
[DeploymentItem(@"Data\PostID.csv", @"Data")]
public async Task DeleteID()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitDelete(effortConnection, "post-i-ds/203");

var responseContent = await response.Content.ReadAsStringAsync();
responseContent.Should().Be("");
response.StatusCode.Should().Be(HttpStatusCode.NoContent);

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allPosts = dbContext.PostsID.ToArray();
allPosts.Length.Should().Be(3);
var actualPosts = allPosts.FirstOrDefault(t => t.ID == "203");
actualPosts.Should().BeNull();
}
}
}

[TestMethod]
[DeploymentItem(@"Data\PostLongId.csv", @"Data")]
public async Task DeleteLongId()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitDelete(effortConnection, "post-long-ids/203");

var responseContent = await response.Content.ReadAsStringAsync();
responseContent.Should().Be("");
response.StatusCode.Should().Be(HttpStatusCode.NoContent);

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allPosts = dbContext.PostsLongId.ToArray();
allPosts.Length.Should().Be(3);
var actualPosts = allPosts.FirstOrDefault(t => t.Id == 203);
actualPosts.Should().BeNull();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"type": "post-i-ds",
"id": "205",
"attributes": {
"title": "Added post",
"content": "Added post content",
"created": "2015-03-11T04:31:00+00:00"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"type": "post-long-ids",
"id": "205",
"attributes": {
"title": "Added post",
"content": "Added post content",
"created": "2015-03-11T04:31:00+00:00"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"type": "post-i-ds",
"id": "205",
"attributes": {
"content": "Added post content",
"created": "2015-03-11T04:31:00.0000000+00:00",
"title": "Added post"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"type": "post-long-ids",
"id": "205",
"attributes": {
"content": "Added post content",
"created": "2015-03-11T04:31:00.0000000+00:00",
"title": "Added post"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": {
"type": "post-i-ds",
"id": "202",
"attributes": {
"title": "New post title"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": {
"type": "post-long-ids",
"id": "202",
"attributes": {
"title": "New post title"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"type": "post-i-ds",
"id": "202",
"attributes": {
"content": "Post 2 content",
"created": "2015-02-05T08:10:00.0000000+00:00",
"title": "New post title"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"type": "post-long-ids",
"id": "202",
"attributes": {
"content": "Post 2 content",
"created": "2015-02-05T08:10:00.0000000+00:00",
"title": "New post title"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@
<None Include="Data\Officer.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\PostLongId.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\PostID.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Data\StarshipOfficerLink.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -240,6 +246,14 @@
<EmbeddedResource Include="Fixtures\Mapped\Responses\Get_related_to_one_response.json" />
<EmbeddedResource Include="Fixtures\Mapped\Responses\Get_related_to_many_response.json" />
<EmbeddedResource Include="Fixtures\FetchingResources\Get_related_to_many_integer_key_response.json" />
<EmbeddedResource Include="Fixtures\CreatingResources\Requests\PostID_with_client_provided_id_Request.json" />
<EmbeddedResource Include="Fixtures\CreatingResources\Responses\PostID_with_client_provided_id_Response.json" />
<EmbeddedResource Include="Fixtures\CreatingResources\Requests\PostLongId_with_client_provided_id_Request.json" />
<EmbeddedResource Include="Fixtures\CreatingResources\Responses\PostLongId_with_client_provided_id_Response.json" />
<EmbeddedResource Include="Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequestID.json" />
<EmbeddedResource Include="Fixtures\UpdatingResources\Responses\PatchWithAttributeUpdateResponseID.json" />
<EmbeddedResource Include="Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequestLongId.json" />
<EmbeddedResource Include="Fixtures\UpdatingResources\Responses\PatchWithAttributeUpdateResponseLongId.json" />
<None Include="packages.config" />
</ItemGroup>
<Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,52 @@ public async Task PatchWithAttributeUpdate()
}
}

[TestMethod]
[DeploymentItem(@"Data\PostID.csv", @"Data")]
public async Task PatchWithAttributeUpdateID()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitPatch(effortConnection, "post-i-ds/202", @"Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequestID.json");

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

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allPosts = dbContext.PostsID;
allPosts.Count().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)));
}
}
}

[TestMethod]
[DeploymentItem(@"Data\PostLongId.csv", @"Data")]
public async Task PatchWithAttributeUpdateLongId()
{
using (var effortConnection = GetEffortConnection())
{
var response = await SubmitPatch(effortConnection, "post-long-ids/202", @"Fixtures\UpdatingResources\Requests\PatchWithAttributeUpdateRequestLongId.json");

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

using (var dbContext = new TestDbContext(effortConnection, false))
{
var allPosts = dbContext.PostsLongId;
allPosts.Count().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)));
}
}
}

[TestMethod]
[DeploymentItem(@"Data\Comment.csv", @"Data")]
[DeploymentItem(@"Data\Post.csv", @"Data")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
<Compile Include="Models\LanguageUserLink.cs" />
<Compile Include="Models\Master.cs" />
<Compile Include="Models\Officer.cs" />
<Compile Include="Models\PostLongId.cs" />
<Compile Include="Models\PostID.cs" />
<Compile Include="Models\Post.cs" />
<Compile Include="Models\Sample.cs" />
<Compile Include="Models\Starship.cs" />
Expand Down Expand Up @@ -204,11 +206,11 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
21 changes: 21 additions & 0 deletions JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp/Models/PostID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models
{
public class PostID
{
[Key]
public string ID { get; set; }

public string Title { get; set; }

public string Content { get; set; }

public DateTimeOffset Created { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;

namespace JSONAPI.AcceptanceTests.EntityFrameworkTestWebApp.Models
{
public class PostLongId
{
[Key]
public long Id { get; set; }

public string Title { get; set; }

public string Content { get; set; }

public DateTimeOffset Created { get; set; }

}
}
Loading