Inheritance: IBaseObject
Exemplo n.º 1
0
 public void JsonConvert_Should_Serialize_Properly()
 {
     var company = new Company();
     company.Name = "Whiteboard-it";
     var settings = new JsonSerializerSettings();
     var converters = new List<JsonConverter> { new IsoDateTimeConverter() };
     settings.Converters = converters;
     settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
     settings.NullValueHandling = NullValueHandling.Ignore;
     var result = JsonConvert.SerializeObject(company, Formatting.Indented, settings);
     Console.Write(result);
     Assert.IsTrue(result.Contains("Whiteboard-it"));
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public void Should_Persist_Property()
 {
     var db = client.GetDatabase(baseDatabase);
     var company = new Company();
     company.Id = "1234";
     company.Name = "Whiteboard-IT";
     db.CreateDocument(company);
     var doc = db.GetDocument<Company>("1234");
     Assert.AreEqual(company.Name, doc.Name);
 }