public void Case8() { var a = new Article() { IdJson = 1, title = "titre", body = "body" }; JsonApiParser parser = this.GetParser(a); parser.AddMeta("metaString", "test"); parser.AddMeta("metaInt", 1); parser.AddMeta("metaList", new List <string>() { "chaine1", "chaine2", "chaine3" }); parser.AddMeta("article", a); parser.AddMeta("listarticle", new List <Article>() { a, a }); var json = (JObject)parser.GetJson(); Assert.Equal(json["meta"]["metaString"].ToString(), "test"); Assert.Equal(json["meta"]["metaInt"].ToString(), "1"); Assert.Equal(json["meta"]["metaList"].Type.ToString(), "Array"); Assert.Equal(json["meta"]["metaList"][0].ToString(), "chaine1"); Assert.Equal(json["meta"]["article"].Type.ToString(), "Object"); Assert.Equal(json["meta"]["article"]["type"].ToString(), "article"); Assert.Equal(json["meta"]["listarticle"].Type.ToString(), "Array"); Assert.Equal(json["meta"]["listarticle"][0]["type"].ToString(), "article"); Assert.Equal(json["meta"]["listarticle"][1]["type"].ToString(), "article"); }
public void Case9() { var dictionnary = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" } }; JsonApiParser parser = this.GetParser(dictionnary); parser.AddMeta("dico", dictionnary); var json = (JObject)parser.GetJson(); Assert.Equal(json["data"].Type.ToString(), "Object"); Assert.Equal(json["data"]["attributes"]["key1"].ToString(), "value1"); Assert.Equal(json["meta"]["dico"]["attributes"]["key1"].ToString(), "value1"); }