public void Column_Property_And_Role_Specified() { //Arrange ------------------ string columnJson; var column = new Column(ColumnType.String); column.Role = ColumnRole.Annotation; column.AddProperty(new Property("property1", "value")); //Act ---------------------- using (var ms = new MemoryStream()) { var sw = new StreamWriter(ms); column.GetJson(sw); sw.Flush(); ms.Position = 0; using (var sr = new StreamReader(ms)) { columnJson = sr.ReadToEnd(); } } //Assert ------------------- Assert.That(columnJson != null); var dictionary = JsonHelper.GetDictionaryFromJson(columnJson); object roleValue; object propValue; var pDictionary = (Dictionary <string, object>)dictionary["p"]; pDictionary.TryGetValue("role", out roleValue); pDictionary.TryGetValue("property1", out propValue); Assert.That(pDictionary != null); Assert.That(pDictionary["role"] != null); Assert.That(((string)roleValue) == ColumnRole.Annotation); Assert.That(((string)propValue) == "value"); }
public void Column_Property_And_Role_Specified() { //Arrange ------------------ string columnJson; string PROP_VALUE = "value"; var column = new Column(ColumnType.String) { Role = ColumnRole.Annotation }; column.AddProperty(new Property("property1", PROP_VALUE)); //Act ---------------------- using (var ms = new MemoryStream()) { var sw = new StreamWriter(ms); column.GetJson(sw); sw.Flush(); ms.Position = 0; using (var sr = new StreamReader(ms)) { columnJson = sr.ReadToEnd(); } } //Assert ------------------- Assert.That(columnJson != null); ColumnTested restoredCol = JsonHelper.GetFromJson <ColumnTested>(columnJson); Assert.That(restoredCol.p.role.ToString() == ColumnRole.Annotation); Assert.That(restoredCol.p.property1.ToString() == PROP_VALUE); }