Skip to content

Commit f54dc4a

Browse files
committed
test(add): integration tests add articles
1 parent 5c55973 commit f54dc4a

File tree

11 files changed

+462
-3
lines changed

11 files changed

+462
-3
lines changed

JsonApiDotnetCore.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportsExample", "src\Examp
3030
EndProject
3131
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OperationsExample", "src\Examples\OperationsExample\OperationsExample.csproj", "{CF2C1EB6-8449-4B35-B8C7-F43D6D90632D}"
3232
EndProject
33+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OperationsExampleTests", "test\OperationsExampleTests\OperationsExampleTests.csproj", "{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}"
34+
EndProject
3335
Global
3436
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3537
Debug|Any CPU = Debug|Any CPU
@@ -124,6 +126,18 @@ Global
124126
{CF2C1EB6-8449-4B35-B8C7-F43D6D90632D}.Release|x64.Build.0 = Release|x64
125127
{CF2C1EB6-8449-4B35-B8C7-F43D6D90632D}.Release|x86.ActiveCfg = Release|x86
126128
{CF2C1EB6-8449-4B35-B8C7-F43D6D90632D}.Release|x86.Build.0 = Release|x86
129+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
130+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
131+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Debug|x64.ActiveCfg = Debug|x64
132+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Debug|x64.Build.0 = Debug|x64
133+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Debug|x86.ActiveCfg = Debug|x86
134+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Debug|x86.Build.0 = Debug|x86
135+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
136+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Release|Any CPU.Build.0 = Release|Any CPU
137+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Release|x64.ActiveCfg = Release|x64
138+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Release|x64.Build.0 = Release|x64
139+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Release|x86.ActiveCfg = Release|x86
140+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1}.Release|x86.Build.0 = Release|x86
127141
EndGlobalSection
128142
GlobalSection(SolutionProperties) = preSolution
129143
HideSolutionNode = FALSE
@@ -138,5 +152,6 @@ Global
138152
{026FBC6C-AF76-4568-9B87-EC73457899FD} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF}
139153
{FBFB0B0B-EA86-4B41-AB2A-E0249F70C86D} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
140154
{CF2C1EB6-8449-4B35-B8C7-F43D6D90632D} = {026FBC6C-AF76-4568-9B87-EC73457899FD}
155+
{9CD2C116-D133-4FE4-97DA-A9FEAFF045F1} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}
141156
EndGlobalSection
142157
EndGlobal

src/JsonApiDotNetCore/AssemblyInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("OperationsExampleTests")]

src/JsonApiDotNetCore/Formatters/JsonApiOperationsInputFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace JsonApiDotNetCore.Formatters
88
{
99
public class JsonApiOperationsInputFormatter : IInputFormatter
1010
{
11-
const string PROFILE_EXTENSION = "<http://example.org/profiles/myjsonstuff>; rel=\"profile\"";
11+
internal const string PROFILE_EXTENSION = "<http://example.org/profiles/myjsonstuff>; rel=\"profile\"";
1212

1313
public bool CanRead(InputFormatterContext context)
1414
{

src/JsonApiDotNetCore/Formatters/JsonApiOperationsReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public Task<InputFormatterResult> ReadAsync(InputFormatterContext context)
2222

2323
var request = context.HttpContext.Request;
2424
if (request.ContentLength == null || request.ContentLength == 0)
25-
return InputFormatterResult.FailureAsync();
25+
throw new JsonApiException(400, "Content-Length cannot be empty.");
2626

2727
var body = GetRequestBody(request.Body);
2828

2929
var operations = JsonConvert.DeserializeObject<OperationsDocument>(body);
3030

31-
if(operations == null)
31+
if (operations == null)
3232
throw new JsonApiException(400, "Failed to deserialize operations request.");
3333

3434
return InputFormatterResult.SuccessAsync(operations);

src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public List<TEntity> DeserializeList<TEntity>(string requestBody)
8080

8181
public object DocumentToObject(DocumentData data)
8282
{
83+
if (data == null) throw new JsonApiException(422, "Failed to deserialize document as json:api.");
84+
8385
var contextEntity = _jsonApiContext.ContextGraph.GetContextEntity(data.Type?.ToString());
8486
_jsonApiContext.RequestEntity = contextEntity;
8587

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
build/
21+
bld/
22+
[Bb]in/
23+
[Oo]bj/
24+
25+
# Visual Studio 2015 cache/options directory
26+
.vs/
27+
# Uncomment if you have tasks that create the project's static files in wwwroot
28+
#wwwroot/
29+
30+
# MSTest test Results
31+
[Tt]est[Rr]esult*/
32+
[Bb]uild[Ll]og.*
33+
34+
# NUNIT
35+
*.VisualState.xml
36+
TestResult.xml
37+
38+
# Build Results of an ATL Project
39+
[Dd]ebugPS/
40+
[Rr]eleasePS/
41+
dlldata.c
42+
43+
# DNX
44+
project.lock.json
45+
artifacts/
46+
47+
*_i.c
48+
*_p.c
49+
*_i.h
50+
*.ilk
51+
*.meta
52+
*.obj
53+
*.pch
54+
*.pdb
55+
*.pgc
56+
*.pgd
57+
*.rsp
58+
*.sbr
59+
*.tlb
60+
*.tli
61+
*.tlh
62+
*.tmp
63+
*.tmp_proj
64+
*.log
65+
*.vspscc
66+
*.vssscc
67+
.builds
68+
*.pidb
69+
*.svclog
70+
*.scc
71+
72+
# Chutzpah Test files
73+
_Chutzpah*
74+
75+
# Visual C++ cache files
76+
ipch/
77+
*.aps
78+
*.ncb
79+
*.opendb
80+
*.opensdf
81+
*.sdf
82+
*.cachefile
83+
84+
# Visual Studio profiler
85+
*.psess
86+
*.vsp
87+
*.vspx
88+
*.sap
89+
90+
# TFS 2012 Local Workspace
91+
$tf/
92+
93+
# Guidance Automation Toolkit
94+
*.gpState
95+
96+
# ReSharper is a .NET coding add-in
97+
_ReSharper*/
98+
*.[Rr]e[Ss]harper
99+
*.DotSettings.user
100+
101+
# JustCode is a .NET coding add-in
102+
.JustCode
103+
104+
# TeamCity is a build add-in
105+
_TeamCity*
106+
107+
# DotCover is a Code Coverage Tool
108+
*.dotCover
109+
110+
# NCrunch
111+
_NCrunch_*
112+
.*crunch*.local.xml
113+
nCrunchTemp_*
114+
115+
# MightyMoose
116+
*.mm.*
117+
AutoTest.Net/
118+
119+
# Web workbench (sass)
120+
.sass-cache/
121+
122+
# Installshield output folder
123+
[Ee]xpress/
124+
125+
# DocProject is a documentation generator add-in
126+
DocProject/buildhelp/
127+
DocProject/Help/*.HxT
128+
DocProject/Help/*.HxC
129+
DocProject/Help/*.hhc
130+
DocProject/Help/*.hhk
131+
DocProject/Help/*.hhp
132+
DocProject/Help/Html2
133+
DocProject/Help/html
134+
135+
# Click-Once directory
136+
publish/
137+
138+
# Publish Web Output
139+
*.[Pp]ublish.xml
140+
*.azurePubxml
141+
# TODO: Comment the next line if you want to checkin your web deploy settings
142+
# but database connection strings (with potential passwords) will be unencrypted
143+
*.pubxml
144+
*.publishproj
145+
146+
# NuGet Packages
147+
*.nupkg
148+
# The packages folder can be ignored because of Package Restore
149+
**/packages/*
150+
# except build/, which is used as an MSBuild target.
151+
!**/packages/build/
152+
# Uncomment if necessary however generally it will be regenerated when needed
153+
#!**/packages/repositories.config
154+
155+
# Microsoft Azure Build Output
156+
csx/
157+
*.build.csdef
158+
159+
# Microsoft Azure Emulator
160+
ecf/
161+
rcf/
162+
163+
# Microsoft Azure ApplicationInsights config file
164+
ApplicationInsights.config
165+
166+
# Windows Store app package directory
167+
AppPackages/
168+
BundleArtifacts/
169+
170+
# Visual Studio cache files
171+
# files ending in .cache can be ignored
172+
*.[Cc]ache
173+
# but keep track of directories ending in .cache
174+
!*.[Cc]ache/
175+
176+
# Others
177+
ClientBin/
178+
~$*
179+
*~
180+
*.dbmdl
181+
*.dbproj.schemaview
182+
*.pfx
183+
*.publishsettings
184+
node_modules/
185+
orleans.codegen.cs
186+
187+
# RIA/Silverlight projects
188+
Generated_Code/
189+
190+
# Backup & report files from converting an old project file
191+
# to a newer Visual Studio version. Backup files are not needed,
192+
# because we have git ;-)
193+
_UpgradeReport_Files/
194+
Backup*/
195+
UpgradeLog*.XML
196+
UpgradeLog*.htm
197+
198+
# SQL Server files
199+
*.mdf
200+
*.ldf
201+
202+
# Business Intelligence projects
203+
*.rdl.data
204+
*.bim.layout
205+
*.bim_*.settings
206+
207+
# Microsoft Fakes
208+
FakesAssemblies/
209+
210+
# GhostDoc plugin setting file
211+
*.GhostDoc.xml
212+
213+
# Node.js Tools for Visual Studio
214+
.ntvs_analysis.dat
215+
216+
# Visual Studio 6 build log
217+
*.plg
218+
219+
# Visual Studio 6 workspace options file
220+
*.opt
221+
222+
# Visual Studio LightSwitch build output
223+
**/*.HTMLClient/GeneratedArtifacts
224+
**/*.DesktopClient/GeneratedArtifacts
225+
**/*.DesktopClient/ModelManifest.xml
226+
**/*.Server/GeneratedArtifacts
227+
**/*.Server/ModelManifest.xml
228+
_Pvt_Extensions
229+
230+
# Paket dependency manager
231+
.paket/paket.exe
232+
233+
# FAKE - F# Make
234+
.fake/

0 commit comments

Comments
 (0)