Skip to content

Commit a6eda8e

Browse files
committed
Merge pull request #119 from WebApiContrib/dev
Dev
2 parents 34596a4 + 7ac700a commit a6eda8e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/CollectionJson/Collection.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public Collection()
3838

3939
[DataMember(Name = "template")]
4040
public Template Template { get; private set; }
41+
42+
[DataMember(Name = "error")]
43+
public Error Error { get; set; }
4144
}
4245

4346
}

src/CollectionJson/CollectionJson.nuspec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<copyright>2013 Glenn Block</copyright>
1515
<tags>collectionjson</tags>
1616
</metadata>
17+
<dependencies>
18+
<dependency id="DynamicUtils" version="1.0.1" />
19+
</dependencies>
1720
<files>
1821
<file src="bin\Release\CollectionJson.dll" target="lib\portable-net40+sl50+win8+wpa81+wp8+monotouch+monoandroid" />
1922
</files>

test/CollectionJson.Client.Tests/CollectionJsonContentTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,26 @@ public async void WhenCreatingCollectionJsonContentObjectIsSerializedToCollectio
2323
var json = reader.ReadToEnd();
2424
json.ShouldContain("\"collection\"");
2525
}
26+
27+
[Fact]
28+
public async void WhenCreatingCollectionJsonContentWithErrorObjectIsSerializedWithError()
29+
{
30+
var coll = new Collection()
31+
{
32+
Error = new Error()
33+
{
34+
Code = "1234",
35+
Message = "Hello world",
36+
Title = "An error occurred"
37+
}
38+
};
39+
var content = new CollectionJsonContent(coll);
40+
var stream = new MemoryStream();
41+
await content.CopyToAsync(stream);
42+
var reader = new StreamReader(stream);
43+
stream.Position = 0;
44+
var json = reader.ReadToEnd();
45+
json.ShouldContain("\"error\"");
46+
}
2647
}
2748
}

0 commit comments

Comments
 (0)