public void Creates_expected_dictionary_with_no_nested_keys() { var row = new InterpretedDataRow(); row.AddValue("key1", "value1"); row.AddValue("key2", "value2"); Assert.Equal("value1", row["key1"]); Assert.Equal("value2", row["key2"]); }
public void Returns_expected_json_for_object() { var data = new InterpretedDataRow(); data.AddValue("key1", "value1"); var nested = data.GetNested("nested"); nested.AddValue("key2", "value2"); var newLine = Environment.NewLine; var expected = $"{{{newLine}" + $" \"key1\": \"value1\",{newLine}" + $" \"nested\": {{{newLine}" + $" \"key2\": \"value2\"{newLine}" + $" }}{newLine}" + $"}}"; var sut = new JsonDataWriter(); var result = sut.WriteData(data); Assert.Equal(StructuredDataFormat.Json, result.Format); Assert.Equal(expected, result.Contents); }
public void Creates_expected_dictionary_with_nested_keys() { var row = new InterpretedDataRow(); row.AddValue("key1", "value1"); var nested = row.GetNested("nested"); nested.AddValue("key2", "nestedValue1"); var inner = nested.GetNested("nested1"); inner.AddValue("key3", "nestedValue2"); Assert.Equal("value1", row["key1"]); Assert.Equal("nestedValue1", row.GetNested("nested")["key2"]); Assert.Equal("nestedValue2", row.GetNested("nested").GetNested("nested1")["key3"]); }