diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/WebServiceDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/WebServiceDataSourceItemFixture.cs index 13388c6..3c1a62f 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/WebServiceDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/WebServiceDataSourceItemFixture.cs @@ -58,77 +58,99 @@ public void RDashDocument_HasCorrectDataSource_WhenLoadFromFile() Assert.NotNull(webServiceDataSource.Properties.GetValue("_rpUseAnonymousAuthentication")); } - //[Fact] - //public void ToJsonString_CreatesFormattedJson_ForWebServiceDataSource() - //{ - // // Arrange - // var expectedJson = - // """ - // { - // "_type": "DataSourceItemType", - // "Id": "webServiceItemId", - // "Title": "Sales by Category", - // "Subtitle": "Excel2Json", - // "DataSourceId": "__JSON", - // "HasTabularData": true, - // "HasAsset": false, - // "Properties": {}, - // "Parameters": {}, - // "ResourceItem": { - // "_type": "DataSourceItemType", - // "Id": "webServiceItemId", - // "Title": "DB Test", - // "Subtitle": "Excel2Json", - // "DataSourceId": "JSON", - // "HasTabularData": true, - // "HasAsset": false, - // "Properties": { - // "Url": "https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9" - // }, - // "Parameters": {} - // } - // } - // """; + [Fact] + public void ToJsonString_CreatesFormattedJson_ForWebServiceDataSource() + { + // Arrange + var expectedJson = + """ + { + "_type": "DataSourceItemType", + "Id": "webServiceItemId", + "Title": "Sales by Category", + "Subtitle": "Excel2Json", + "DataSourceId": "__JSON", + "HasTabularData": true, + "HasAsset": false, + "Properties": {}, + "Parameters": { + "config": { + "iterationDepth": 0, + "columnsConfig": [ + { + "key": "CategoryID", + "type": 1 + }, + { + "key": "CategoryName", + "type": 0 + }, + { + "key": "ProductName", + "type": 0 + }, + { + "key": "ProductSales", + "type": 1 + } + ] + } + }, + "ResourceItem": { + "_type": "DataSourceItemType", + "Id": "webServiceItemId", + "Title": "DB Test", + "Subtitle": "Excel2Json", + "DataSourceId": "JSON", + "HasTabularData": true, + "HasAsset": false, + "Properties": { + "Url": "https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9" + }, + "Parameters": {} + } + } + """; - // var dataSource = new DataSource() - // { - // Id = "JSON", - // Title = "JSON Data Source", - // Subtitle = "JSON Data Source Subtitle", - // }; + var dataSource = new DataSource() + { + Id = "JSON", + Title = "JSON Data Source", + Subtitle = "JSON Data Source Subtitle", + }; - // var dataSourceItems = new WebServiceDataSourceItem("DB Test", dataSource) - // { - // Id = "webServiceItemId", - // Title = "Sales by Category", - // Subtitle = "Excel2Json", - // Uri = "https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9", - // Fields = new List - // { - // new NumberField("CategoryID"), - // new TextField("CategoryName"), - // new TextField("ProductName"), - // new NumberField("ProductSales"), - // } - // }; + var dataSourceItems = new WebServiceDataSourceItem("DB Test", dataSource) + { + Id = "webServiceItemId", + Title = "Sales by Category", + Subtitle = "Excel2Json", + Uri = "https://excel2json.io/api/share/6e0f06b3-72d3-4fec-7984-08da43f56bb9", + Fields = new List + { + new NumberField("CategoryID"), + new TextField("CategoryName"), + new TextField("ProductName"), + new NumberField("ProductSales"), + } + }; - // var document = new RdashDocument("My Dashboard"); - // document.Visualizations.Add( - // new ColumnChartVisualization("Test List", dataSourceItems) - // .SetLabel("CategoryName") - // .SetValue("ProductName") - // ); + var document = new RdashDocument("My Dashboard"); + document.Visualizations.Add( + new ColumnChartVisualization("Test List", dataSourceItems) + .SetLabel("CategoryName") + .SetValue("ProductName") + ); - // var expectedJObject = JObject.Parse(expectedJson); + var expectedJObject = JObject.Parse(expectedJson); - // // Act - // RdashSerializer.SerializeObject(document); - // var json = document.ToJsonString(); - // var jObject = JObject.Parse(json); - // var actualJObject = jObject["Widgets"].FirstOrDefault()["DataSpec"]["DataSourceItem"]; + // Act + RdashSerializer.SerializeObject(document); + var json = document.ToJsonString(); + var jObject = JObject.Parse(json); + var actualJObject = jObject["Widgets"].FirstOrDefault()["DataSpec"]["DataSourceItem"]; - // // Assert - // Assert.Equal(expectedJObject, actualJObject); - //} + // Assert + Assert.Equal(expectedJObject, actualJObject); + } } } \ No newline at end of file