diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf74ac60..fb55ae44 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,10 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 + - name: Install Mono + run: | + sudo apt-get update + sudo apt-get install -y mono-complete - name: Setup .NET uses: actions/setup-dotnet@v2 with: diff --git a/src/Reveal.Sdk.Dom.Tests/Visualizations/VisualizationSpecs/SparklineVisualizationDataSpecFixture.cs b/src/Reveal.Sdk.Dom.Tests/Visualizations/VisualizationSpecs/SparklineVisualizationDataSpecFixture.cs new file mode 100644 index 00000000..d60aa764 --- /dev/null +++ b/src/Reveal.Sdk.Dom.Tests/Visualizations/VisualizationSpecs/SparklineVisualizationDataSpecFixture.cs @@ -0,0 +1,66 @@ +using Newtonsoft.Json.Linq; +using Reveal.Sdk.Dom.Core.Constants; +using Reveal.Sdk.Dom.Visualizations; +using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; +using System.Collections.Generic; +using Xunit; + +namespace Reveal.Sdk.Dom.Tests.Visualizations.VisualizationSpecs +{ + public class SparklineVisualizationDataSpecFixture + { + [Fact] + public void Constructor_FieldsHaveDefaultValue() + { + // Act + var sparklineVSDataSpec = new SparklineVisualizationDataSpec(); + + // Assert + Assert.Equal(SchemaTypeNames.SparklineVisualizationDataSpecType, sparklineVSDataSpec.SchemaTypeName); + Assert.Equal(IndicatorVisualizationType.LastMonths, sparklineVSDataSpec.IndicatorType); + } + + [Fact] + public void ToJsonString_CreateCorrectJsonString_WithoutCondition() + { + // Arrange + var expectedJson = """ + { + "_type": "BubbleVisualizationDataSpecType", + "NumberOfPeriods": 3, + "ShowIndicator": false, + "IndicatorType": "YearToDatePreviousYear", + "Date": { + "_type": "DimensionColumnSpecType" + }, + "Value": [], + "AdHocFields": 12, + "FormatVersion": 2, + "AdHocExpandedElements": [], + "Rows": [] + } + """; + var sparklineVSDataSpec = new SparklineVisualizationDataSpec() + { + AdHocExpandedElements = new List(), + AdHocFields = 12, + Date = new DimensionColumn(), + FormatVersion = 2, + IndicatorType = IndicatorVisualizationType.YearToDatePreviousYear, + NumberOfPeriods =3, + Rows = new List(), + SchemaTypeName = SchemaTypeNames.BubbleVisualizationDataSpecType, + ShowIndicator = false, + Value = new List() + }; + + // Act + var actualJson = sparklineVSDataSpec.ToJsonString(); + var expectedJObject = JObject.Parse(expectedJson); + var actualJObject = JObject.Parse(actualJson); + + // Assert + Assert.Equal(expectedJObject, actualJObject); + } + } +}