Permalink
Browse files

Add integration test for IncludeDocs feature

  • Loading branch information...
1 parent 0b5384d commit d576655d8076d752a091415ee92e00cfa39ca95e @pagebrooks pagebrooks committed Dec 6, 2012
Showing with 39 additions and 0 deletions.
  1. +39 −0 LoveSeat.IntegrationTest/CouchClientTest.cs
@@ -219,6 +219,45 @@ public void Should_Get_Id_From_Existing_Document()
Document doc= db.GetDocument(id);
Assert.AreEqual(id, doc.Id);
}
+
+ [Test]
+ public void Should_Populate_Items_When_IncludeDocs_Set_In_ViewOptions()
+ {
+ string designDoc = "test";
+ string viewName = "testView";
+ var settings = new JsonSerializerSettings();
+ var converters = new List<JsonConverter> { new IsoDateTimeConverter() };
+ settings.Converters = converters;
+ settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
+ settings.NullValueHandling = NullValueHandling.Ignore;
+
+ var doc = new
+ {
+ _id = "_design/" + designDoc,
+ Language = "javascript",
+ Views = new
+ {
+ TestView = new
+ {
+ Map = "function(doc) {\n if(doc.type == 'company') {\n emit(doc._id, null);\n }\n}"
+ }
+ }
+ };
+
+ var db = client.GetDatabase(baseDatabase);
+ db.CreateDocument(doc._id, JsonConvert.SerializeObject(doc, Formatting.Indented, settings));
+
+ var company = new Company();
+ company.Name = "foo";
+ db.CreateDocument(company);
+
+ // Without IncludeDocs
+ Assert.IsNull(db.View<Company>(viewName, designDoc).Items.ToList()[0]);
+
+ // With IncludeDocs
+ ViewOptions options = new ViewOptions { IncludeDocs = true };
+ Assert.AreEqual("foo", db.View<Company>(viewName, options, designDoc).Items.ToList()[0].Name);
+ }
}
public class Company : IBaseObject
{

0 comments on commit d576655

Please sign in to comment.