Skip to content

Commit

Permalink
v2.0 Initial commit
Browse files Browse the repository at this point in the history
- Support heterogenous documents
- Type inference / Type detection
- Custom PropertyType and ResourceType resolvers
- Dependency Injection
- Full coverage of README examples in tests
  • Loading branch information
Shaun Guth committed Jul 28, 2015
1 parent 359e1e9 commit ccfe5b4
Show file tree
Hide file tree
Showing 66 changed files with 1,801 additions and 923 deletions.
32 changes: 0 additions & 32 deletions JsonApiNet.Tests/Conversion/ComplexArticleTests.cs

This file was deleted.

45 changes: 0 additions & 45 deletions JsonApiNet.Tests/Conversion/CompoundResourceTests.cs

This file was deleted.

28 changes: 0 additions & 28 deletions JsonApiNet.Tests/Conversion/SingularResourceTests.cs

This file was deleted.

11 changes: 11 additions & 0 deletions JsonApiNet.Tests/Data/ReadmeAttributeTypeResolution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"data": {
"type": "ghost_busters",
"id": "Egon Spengler",
"attributes": {
"quotes": [
"I collect spores, molds, and fungus."
],
}
}
}
61 changes: 61 additions & 0 deletions JsonApiNet.Tests/Data/ReadmeCompoundDocument.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"data": [{
"type": "articles",
"id": "30cd428f-1a3b-459b-a9a8-0ca87c14dd31",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"links": {
"self": "http://example.com/articles/1"
},
"relationships": {
"author": {
"links": {
"self": "http://example.com/articles/1/relationships/author",
"related": "http://example.com/articles/1/author"
},
"data": { "type": "people", "id": "9" }
},
"comments": {
"links": {
"self": "http://example.com/articles/1/relationships/comments",
"related": "http://example.com/articles/1/comments"
},
"data": [
{ "type": "comments", "id": "5" },
{ "type": "comments", "id": "12" }
]
}
}
}],
"included": [{
"type": "people",
"id": "9",
"attributes": {
"first-name": "Dan",
"last-name": "Gebhardt",
"twitter": "dgeb"
},
"links": {
"self": "http://example.com/people/9"
}
}, {
"type": "comments",
"id": "5",
"attributes": {
"body": "First!"
},
"links": {
"self": "http://example.com/comments/5"
}
}, {
"type": "comments",
"id": "12",
"attributes": {
"body": "I like XML better"
},
"links": {
"self": "http://example.com/comments/12"
}
}]
}
21 changes: 21 additions & 0 deletions JsonApiNet.Tests/Data/ReadmeMixedResources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"data": [{
"type": "articles",
"id": "30cd428f-1a3b-459b-a9a8-0ca87c14dd31",
"attributes": {
"title": "JSON API paints my bikeshed!"
}
},{
"type": "books",
"id": "4062e824-544c-41c9-9ef0-f05d03476d1e",
"attributes": {
"title": "and I wrote a book about it..."
}
},{
"type": "magazines",
"id": "85b03dc1-8f43-4660-809d-b3869ca0935a",
"attributes": {
"title": "which was featured in a magazine!"
}
}]
}
9 changes: 9 additions & 0 deletions JsonApiNet.Tests/Data/ReadmeMultipleResources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": [{
"type": "articles",
"id": "30cd428f-1a3b-459b-a9a8-0ca87c14dd31",
"attributes": {
"title": "JSON API paints my bikeshed!"
}
}]
}
9 changes: 9 additions & 0 deletions JsonApiNet.Tests/Data/ReadmeResourceTypeResolution.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": {
"type": "rain_drops",
"id": "1234",
"attributes": {
"splatter": true
}
}
}
9 changes: 9 additions & 0 deletions JsonApiNet.Tests/Data/ReadmeSingleResource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"data": {
"type": "articles",
"id": "30cd428f-1a3b-459b-a9a8-0ca87c14dd31",
"attributes": {
"title": "JSON API paints my bikeshed!"
}
}
}
48 changes: 39 additions & 9 deletions JsonApiNet.Tests/Data/TestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,55 @@ public static class TestData
{
public static string ValidDocumentErrorsJson()
{
return ReadExample("ValidDocumentErrors.json");
return ReadEmbeddedResource("ValidDocumentErrors.json");
}

public static string ValidDocumentSimpleJson()
{
return ReadExample("ValidDocumentSimple.json");
return ReadEmbeddedResource("ValidDocumentSimple.json");
}

public static string ValidDocumentCompoundJson()
{
return ReadExample("ValidDocumentCompound.json");
return ReadEmbeddedResource("ValidDocumentCompound.json");
}

private static string ReadExample(string key)
public static string ValidDocumentComplexTypesJson()
{
return ReadEmbeddedResource("ValidDocumentComplexTypes.json");
}

public static string ReadmeSingleResourceJson()
{
return ReadEmbeddedResource("ReadmeSingleResource.json");
}

public static string ReadmeMultipleResourcesJson()
{
return ReadEmbeddedResource("ReadmeMultipleResources.json");
}

public static string ReadmeCompoundDocumentJson()
{
return ReadEmbeddedResource("ReadmeCompoundDocument.json");
}

public static string ReadmeMixedResourcesJson()
{
return ReadEmbeddedResource("ReadmeMixedResources.json");
}

public static string ReadmeAttributeTypeResolutionJson()
{
return ReadEmbeddedResource("ReadmeAttributeTypeResolution.json");
}

public static string ReadmeResourceTypeResolutionJson()
{
return ReadEmbeddedResource("ReadmeResourceTypeResolution.json");
}

private static string ReadEmbeddedResource(string key)
{
var assembly = Assembly.GetExecutingAssembly();

Expand All @@ -40,10 +75,5 @@ private static string ReadExample(string key)
}
}
}

public static string ValidDocumentComplexTypesJson()
{
return ReadExample("ValidDocumentComplexTypes.json");
}
}
}
26 changes: 17 additions & 9 deletions JsonApiNet.Tests/JsonApiNet.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,21 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="Conversion\CompoundResourceTests.cs" />
<Compile Include="Conversion\ComplexArticleTests.cs" />
<Compile Include="Data\TestData.cs" />
<Compile Include="Models\ComplexArticle.cs" />
<Compile Include="Models\CompoundArticle.cs" />
<Compile Include="Parsing\CompoundDocumentTests.cs" />
<Compile Include="Parsing\ErrorsDocumentTests.cs" />
<Compile Include="Parsing\SimpleDocumentTests.cs" />
<Compile Include="Models\SimpleArticle.cs" />
<Compile Include="Models\Comment.cs" />
<Compile Include="Models\Person.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Conversion\SingularResourceTests.cs" />
<Compile Include="Readme\IdTypePropertyResolution\ReadmeIdTypePropertyResolutionTests.cs" />
<Compile Include="Readme\AttributeTypeResolution\ReadmeAttributeTypeResolutionTests.cs" />
<Compile Include="Readme\RelationshipPropertyResolution\ReadmeRelationshipPropertyResolutionTests.cs" />
<Compile Include="Readme\CompoundDocument\ReadmeCompoundDocumentTests.cs" />
<Compile Include="Readme\CustomPropertyResolver\ReadmeCustomPropertyResolverTests.cs" />
<Compile Include="Readme\MixedResources\ReadmeMixedResourceTests.cs" />
<Compile Include="Readme\MultipleResources\ReadmeMultipleResourcesTests.cs" />
<Compile Include="Readme\AttributePropertyResolution\ReadmeAttributePropertyResolutionTests.cs" />
<Compile Include="Readme\ResourceTypeResolution\ReadmeResourceTypeResolutionTests.cs" />
<Compile Include="Readme\SingleResource\ReadmeSingleResourceTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JsonApiNet\JsonApiNet.csproj">
Expand All @@ -80,9 +82,15 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Data\ValidDocumentErrors.json" />
<EmbeddedResource Include="Data\ValidDocumentSimple.json" />
<EmbeddedResource Include="Data\ReadmeMultipleResources.json" />
<EmbeddedResource Include="Data\ValidDocumentCompound.json" />
<EmbeddedResource Include="Data\ValidDocumentComplexTypes.json" />
<EmbeddedResource Include="Data\ValidDocumentSimple.json" />
<EmbeddedResource Include="Data\ReadmeAttributeTypeResolution.json" />
<EmbeddedResource Include="Data\ReadmeCompoundDocument.json" />
<EmbeddedResource Include="Data\ReadmeMixedResources.json" />
<EmbeddedResource Include="Data\ReadmeSingleResource.json" />
<EmbeddedResource Include="Data\ReadmeResourceTypeResolution.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
Expand Down
8 changes: 0 additions & 8 deletions JsonApiNet.Tests/Models/Comment.cs

This file was deleted.

29 changes: 0 additions & 29 deletions JsonApiNet.Tests/Models/ComplexArticle.cs

This file was deleted.

Loading

0 comments on commit ccfe5b4

Please sign in to comment.