Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 500fa8c

Browse files
author
Chris Santero
committed
add acceptance tests
1 parent f179e80 commit 500fa8c

38 files changed

Lines changed: 1238 additions & 48 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using JSONAPI.Core;
2+
using JSONAPI.EntityFramework.Http;
3+
using JSONAPI.EntityFramework.Tests.TestWebApp.Models;
4+
5+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Controllers
6+
{
7+
public class CommentsController : ApiController<Comment, TestDbContext>
8+
{
9+
protected readonly TestDbContext DbContext;
10+
11+
public CommentsController(TestDbContext dbContext)
12+
{
13+
DbContext = dbContext;
14+
}
15+
16+
protected override IMaterializer MaterializerFactory()
17+
{
18+
return new EntityFrameworkMaterializer(DbContext);
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using JSONAPI.Core;
2+
using JSONAPI.EntityFramework.Http;
3+
using JSONAPI.EntityFramework.Tests.TestWebApp.Models;
4+
5+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Controllers
6+
{
7+
public class PostsController : ApiController<Post, TestDbContext>
8+
{
9+
protected readonly TestDbContext DbContext;
10+
11+
public PostsController(TestDbContext dbContext)
12+
{
13+
DbContext = dbContext;
14+
}
15+
16+
protected override IMaterializer MaterializerFactory()
17+
{
18+
return new EntityFrameworkMaterializer(DbContext);
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using JSONAPI.Core;
2+
using JSONAPI.EntityFramework.Http;
3+
using JSONAPI.EntityFramework.Tests.TestWebApp.Models;
4+
5+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Controllers
6+
{
7+
public class TagsController : ApiController<Tag, TestDbContext>
8+
{
9+
protected readonly TestDbContext DbContext;
10+
11+
public TagsController(TestDbContext dbContext)
12+
{
13+
DbContext = dbContext;
14+
}
15+
16+
protected override IMaterializer MaterializerFactory()
17+
{
18+
return new EntityFrameworkMaterializer(DbContext);
19+
}
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using JSONAPI.Core;
2+
using JSONAPI.EntityFramework.Http;
3+
using JSONAPI.EntityFramework.Tests.TestWebApp.Models;
4+
5+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Controllers
6+
{
7+
public class UsersController : ApiController<User, TestDbContext>
8+
{
9+
protected readonly TestDbContext DbContext;
10+
11+
public UsersController(TestDbContext dbContext)
12+
{
13+
DbContext = dbContext;
14+
}
15+
16+
protected override IMaterializer MaterializerFactory()
17+
{
18+
return new EntityFrameworkMaterializer(DbContext);
19+
}
20+
}
21+
}
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProductVersion>
8+
</ProductVersion>
9+
<SchemaVersion>2.0</SchemaVersion>
10+
<ProjectGuid>{76DEE472-723B-4BE6-8B97-428AC326E30F}</ProjectGuid>
11+
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
12+
<OutputType>Library</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<RootNamespace>JSONAPI.EntityFramework.Tests.TestWebApp</RootNamespace>
15+
<AssemblyName>JSONAPI.EntityFramework.Tests.TestWebApp</AssemblyName>
16+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
17+
<UseIISExpress>true</UseIISExpress>
18+
<IISExpressSSLPort />
19+
<IISExpressAnonymousAuthentication />
20+
<IISExpressWindowsAuthentication />
21+
<IISExpressUseClassicPipelineMode />
22+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
23+
<RestorePackages>true</RestorePackages>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
26+
<DebugSymbols>true</DebugSymbols>
27+
<DebugType>full</DebugType>
28+
<Optimize>false</Optimize>
29+
<OutputPath>bin\</OutputPath>
30+
<DefineConstants>DEBUG;TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
35+
<DebugType>pdbonly</DebugType>
36+
<Optimize>true</Optimize>
37+
<OutputPath>bin\</OutputPath>
38+
<DefineConstants>TRACE</DefineConstants>
39+
<ErrorReport>prompt</ErrorReport>
40+
<WarningLevel>4</WarningLevel>
41+
</PropertyGroup>
42+
<ItemGroup>
43+
<Reference Include="Autofac">
44+
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
45+
</Reference>
46+
<Reference Include="Autofac.Integration.Owin">
47+
<HintPath>..\packages\Autofac.Owin.3.1.0\lib\net45\Autofac.Integration.Owin.dll</HintPath>
48+
</Reference>
49+
<Reference Include="Autofac.Integration.WebApi">
50+
<HintPath>..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll</HintPath>
51+
</Reference>
52+
<Reference Include="Autofac.Integration.WebApi.Owin">
53+
<HintPath>..\packages\Autofac.WebApi2.Owin.3.2.0\lib\net45\Autofac.Integration.WebApi.Owin.dll</HintPath>
54+
</Reference>
55+
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
56+
<SpecificVersion>False</SpecificVersion>
57+
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll</HintPath>
58+
</Reference>
59+
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
60+
<SpecificVersion>False</SpecificVersion>
61+
<HintPath>..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
62+
</Reference>
63+
<Reference Include="Microsoft.CSharp" />
64+
<Reference Include="Microsoft.Owin">
65+
<HintPath>..\packages\Microsoft.Owin.3.0.0\lib\net45\Microsoft.Owin.dll</HintPath>
66+
</Reference>
67+
<Reference Include="Microsoft.Owin.Host.SystemWeb">
68+
<HintPath>..\packages\Microsoft.Owin.Host.SystemWeb.3.0.0\lib\net45\Microsoft.Owin.Host.SystemWeb.dll</HintPath>
69+
</Reference>
70+
<Reference Include="Newtonsoft.Json">
71+
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
72+
</Reference>
73+
<Reference Include="Owin">
74+
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
75+
</Reference>
76+
<Reference Include="System.Net.Http" />
77+
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
78+
<SpecificVersion>False</SpecificVersion>
79+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath>
80+
</Reference>
81+
<Reference Include="System.Web.DynamicData" />
82+
<Reference Include="System.Web.Entity" />
83+
<Reference Include="System.Web.ApplicationServices" />
84+
<Reference Include="System.ComponentModel.DataAnnotations" />
85+
<Reference Include="System" />
86+
<Reference Include="System.Data" />
87+
<Reference Include="System.Core" />
88+
<Reference Include="System.Data.DataSetExtensions" />
89+
<Reference Include="System.Web.Extensions" />
90+
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
91+
<SpecificVersion>False</SpecificVersion>
92+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath>
93+
</Reference>
94+
<Reference Include="System.Web.Http.Owin">
95+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.2\lib\net45\System.Web.Http.Owin.dll</HintPath>
96+
</Reference>
97+
<Reference Include="System.Xml.Linq" />
98+
<Reference Include="System.Drawing" />
99+
<Reference Include="System.Web" />
100+
<Reference Include="System.Xml" />
101+
<Reference Include="System.Configuration" />
102+
<Reference Include="System.Web.Services" />
103+
<Reference Include="System.EnterpriseServices" />
104+
</ItemGroup>
105+
<ItemGroup>
106+
<Content Include="packages.config" />
107+
<None Include="Web.Debug.config">
108+
<DependentUpon>Web.config</DependentUpon>
109+
</None>
110+
<None Include="Web.Release.config">
111+
<DependentUpon>Web.config</DependentUpon>
112+
</None>
113+
</ItemGroup>
114+
<ItemGroup>
115+
<Content Include="Web.config" />
116+
</ItemGroup>
117+
<ItemGroup>
118+
<Compile Include="Controllers\CommentsController.cs" />
119+
<Compile Include="Controllers\UsersController.cs" />
120+
<Compile Include="Controllers\TagsController.cs" />
121+
<Compile Include="Controllers\PostsController.cs" />
122+
<Compile Include="Models\Comment.cs" />
123+
<Compile Include="Models\Post.cs" />
124+
<Compile Include="Models\Tag.cs" />
125+
<Compile Include="Models\TestDbContext.cs" />
126+
<Compile Include="Models\User.cs" />
127+
<Compile Include="Properties\AssemblyInfo.cs" />
128+
<Compile Include="Startup.cs" />
129+
</ItemGroup>
130+
<ItemGroup>
131+
<ProjectReference Include="..\JSONAPI.EntityFramework\JSONAPI.EntityFramework.csproj">
132+
<Project>{e906356c-93f6-41f6-9a0d-73b8a99aa53c}</Project>
133+
<Name>JSONAPI.EntityFramework</Name>
134+
</ProjectReference>
135+
<ProjectReference Include="..\JSONAPI\JSONAPI.csproj">
136+
<Project>{52b19fd6-efaa-45b5-9c3e-a652e27608d1}</Project>
137+
<Name>JSONAPI</Name>
138+
</ProjectReference>
139+
</ItemGroup>
140+
<PropertyGroup>
141+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
142+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
143+
</PropertyGroup>
144+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
145+
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
146+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
147+
<ProjectExtensions>
148+
<VisualStudio>
149+
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
150+
<WebProjectProperties>
151+
<UseIIS>True</UseIIS>
152+
<AutoAssignPort>True</AutoAssignPort>
153+
<DevelopmentServerPort>9283</DevelopmentServerPort>
154+
<DevelopmentServerVPath>/</DevelopmentServerVPath>
155+
<IISUrl>http://localhost:9283/</IISUrl>
156+
<NTLMAuthentication>False</NTLMAuthentication>
157+
<UseCustomServer>False</UseCustomServer>
158+
<CustomServerUrl>
159+
</CustomServerUrl>
160+
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
161+
</WebProjectProperties>
162+
</FlavorProperties>
163+
</VisualStudio>
164+
</ProjectExtensions>
165+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
166+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
167+
<PropertyGroup>
168+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
169+
</PropertyGroup>
170+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
171+
</Target>
172+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
173+
Other similar extension points exist, see Microsoft.Common.targets.
174+
<Target Name="BeforeBuild">
175+
</Target>
176+
<Target Name="AfterBuild">
177+
</Target>
178+
-->
179+
</Project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.ComponentModel.DataAnnotations;
3+
using System.ComponentModel.DataAnnotations.Schema;
4+
using Newtonsoft.Json;
5+
6+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Models
7+
{
8+
public class Comment
9+
{
10+
[Key]
11+
public string Id { get; set; }
12+
13+
public string Text { get; set; }
14+
15+
public DateTimeOffset Created { get; set; }
16+
17+
[Required]
18+
[JsonIgnore]
19+
public string PostId { get; set; }
20+
21+
[Required]
22+
[JsonIgnore]
23+
public string AuthorId { get; set; }
24+
25+
[ForeignKey("PostId")]
26+
public virtual Post Post { get; set; }
27+
28+
[ForeignKey("AuthorId")]
29+
public virtual User Author { get; set; }
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.ComponentModel.DataAnnotations.Schema;
5+
using Newtonsoft.Json;
6+
7+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Models
8+
{
9+
public class Post
10+
{
11+
[Key]
12+
public string Id { get; set; }
13+
14+
public string Title { get; set; }
15+
16+
public string Content { get; set; }
17+
18+
public DateTimeOffset Created { get; set; }
19+
20+
[Required]
21+
[JsonIgnore]
22+
public string AuthorId { get; set; }
23+
24+
[ForeignKey("AuthorId")]
25+
public virtual User Author { get; set; }
26+
27+
public virtual ICollection<Comment> Comments { get; set; }
28+
29+
public virtual ICollection<Tag> Tags { get; set; }
30+
}
31+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
using System.ComponentModel.DataAnnotations;
3+
4+
namespace JSONAPI.EntityFramework.Tests.TestWebApp.Models
5+
{
6+
public class Tag
7+
{
8+
[Key]
9+
public string Id { get; set; }
10+
11+
public string Name { get; set; }
12+
13+
public virtual ICollection<Post> Posts { get; set; }
14+
}
15+
}

0 commit comments

Comments
 (0)