public void ToJSON_IncludesAddedTables() { //Arrange string sample = "{\"table_1\":[{\"name\":\"sam\", \"age\":42},{\"name\":\"tom\", \"age\":77}],\"table_2\":[{\"name\":\"sam\", \"favorite-Food\":\"pizza\"},{\"name\":\"tom\", \"favorite-Food\":\"apples\"}]}"; JObject sampleObject = JObject.Parse(sample); IReportContainer reportContainer = new ReportContainer(new Dummy_UniqueNameProvider()); ICSVTable table_1 = new Dummy_CSVTable("[{\"name\":\"sam\", \"age\":42},{\"name\":\"tom\", \"age\":77}]"); ICSVTable table_2 = new Dummy_CSVTable("[{\"name\":\"sam\", \"favorite-Food\":\"pizza\"},{\"name\":\"tom\", \"favorite-Food\":\"apples\"}]"); reportContainer.AddTable("table_1", table_1); reportContainer.AddTable("table_2", table_2); bool expected = true; //Act string resultJSON = reportContainer.ToJSON(); bool actual = resultJSON == sampleObject.ToString(); //Assert Assert.AreEqual(expected, actual); }
public void ToJSON_IncludesAddedProperties() { //Arrange string sample = "{\n" + "\"name\": \"report\",\n" + "\"measure\": \"pounds\"\n" + "}"; JObject sampleObject = JObject.Parse(sample); IReportContainer reportContainer = new ReportContainer(new Dummy_UniqueNameProvider()); reportContainer.AddProperty("name", "report"); reportContainer.AddProperty("measure", "pounds"); bool expected = true; //Act string jsonResult = reportContainer.ToJSON(); bool actual = sampleObject.ToString() == jsonResult; //Assert Assert.AreEqual(expected, actual); }