-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into visualization/grid-pivot
- Loading branch information
Showing
5 changed files
with
365 additions
and
0 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ILabelsExtensions.csFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using Moq; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class ILabelsExtensions | ||
{ | ||
[Fact] | ||
public void SetLabel_UpdateLabels_WithFieldName() | ||
{ | ||
// Arrange | ||
var mockLabel = new Mock<ILabels>(); | ||
mockLabel.Setup(x => x.Labels).Returns(new List<DimensionColumn> { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockLabel.Object; | ||
|
||
var fieldName = "TestName"; | ||
var expectedLabels = new List<DimensionColumn> { new DimensionColumn() { DataField = new TextDataField(fieldName) } }; | ||
|
||
// Act | ||
visualization.SetLabel(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedLabels, visualization.Labels); | ||
} | ||
|
||
[Fact] | ||
public void SetLabel_UpdateLabels_WithDimensionDataField() | ||
{ | ||
// Arrange | ||
var mockLabel = new Mock<ILabels>(); | ||
mockLabel.Setup(x => x.Labels).Returns(new List<DimensionColumn> { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockLabel.Object; | ||
|
||
var mockDimensionDataField = new Mock<DimensionDataField>("TestField"); | ||
var dimensionDataField = mockDimensionDataField.Object; | ||
var expectedLabels = new List<DimensionColumn> { new DimensionColumn() { DataField = dimensionDataField } }; | ||
|
||
// Act | ||
visualization.SetLabel(dimensionDataField); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedLabels, visualization.Labels); | ||
} | ||
|
||
[Fact] | ||
public void SetLabels_UpdateLabels_WithListFieldNames() | ||
{ | ||
// Arrange | ||
var mockLabel = new Mock<ILabels>(); | ||
mockLabel.Setup(x => x.Labels).Returns(new List<DimensionColumn> { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockLabel.Object; | ||
|
||
var listFieldNames = new List<string> | ||
{ | ||
"FirstField", | ||
"SecondField" | ||
}; | ||
var expectedLabels = listFieldNames.Select(fieldName => new DimensionColumn() | ||
{ | ||
DataField = new TextDataField(fieldName) | ||
}).ToList(); | ||
|
||
// Act | ||
visualization.SetLabels(listFieldNames.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedLabels, visualization.Labels); | ||
} | ||
|
||
[Fact] | ||
public void SetLabels_UpdateLabels_WithListDimensionDateFields() | ||
{ | ||
// Arrange | ||
var mockLabel = new Mock<ILabels>(); | ||
mockLabel.Setup(x => x.Labels).Returns(new List<DimensionColumn> { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockLabel.Object; | ||
|
||
var listFields = new List<DimensionDataField>(); | ||
var expectedLabels = new List<DimensionColumn>(); | ||
|
||
var mockDimensionDataField1 = new Mock<DimensionDataField>("FirstField"); | ||
var firstField = mockDimensionDataField1.Object; | ||
listFields.Add(firstField); | ||
expectedLabels.Add(new DimensionColumn(firstField)); | ||
|
||
var mockDimensionDataField2 = new Mock<DimensionDataField>("SecondField"); | ||
var secondField = mockDimensionDataField2.Object; | ||
listFields.Add(secondField); | ||
expectedLabels.Add(new DimensionColumn(secondField)); | ||
|
||
// Act | ||
visualization.SetLabels(listFields.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedLabels, visualization.Labels); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/IMapExtensionsFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Moq; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class IMapExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetMap_UpdateMap_WithMapName() | ||
{ | ||
// Arrange | ||
var map = new MockMap(); | ||
var expectedMapName = "TestMap"; | ||
|
||
// Act | ||
map.SetMap(expectedMapName); | ||
|
||
// Assert | ||
Assert.Equal(expectedMapName, map.Map); | ||
} | ||
|
||
private class MockMap : IMap | ||
{ | ||
public string Map { get; set; } | ||
} | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/IRowsExtensionsFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using Moq; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class IRowsExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetRow_UpdateRows_WithFieldName() | ||
{ | ||
// Arrange | ||
var mockRow = new Mock<IRows>(); | ||
mockRow.Setup(s => s.Rows).Returns(new List<DimensionColumn>() { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockRow.Object; | ||
|
||
var fieldName = "TestField"; | ||
var expectedRows = new List<DimensionColumn> { new DimensionColumn() { DataField = new TextDataField(fieldName) } }; | ||
|
||
// Act | ||
visualization.SetRow(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedRows, visualization.Rows); | ||
} | ||
|
||
[Fact] | ||
public void SetRow_UpdateRows_WithDimensionDataField() | ||
{ | ||
// Arrange | ||
var mockRow = new Mock<IRows>(); | ||
mockRow.Setup(s => s.Rows).Returns(new List<DimensionColumn>() { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockRow.Object; | ||
|
||
var mockDimensionDataField = new Mock<DimensionDataField>("TestField"); | ||
var field = mockDimensionDataField.Object; | ||
var expectedRows = new List<DimensionColumn> { new DimensionColumn() { DataField = field } }; | ||
|
||
// Act | ||
visualization.SetRow(field); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedRows, visualization.Rows); | ||
} | ||
|
||
[Fact] | ||
public void SetRows_UpdateRows_WithFieldNames() | ||
{ | ||
// Arrange | ||
var mockRow = new Mock<IRows>(); | ||
mockRow.Setup(s => s.Rows).Returns(new List<DimensionColumn>() { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockRow.Object; | ||
|
||
var fieldNames = new List<string>{ "FirstField", "SecondField" }; | ||
var expectedVSRows = fieldNames.Select(fieldName => new DimensionColumn() { DataField= new TextDataField(fieldName) }); | ||
|
||
// Act | ||
visualization.SetRows(fieldNames.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedVSRows, visualization.Rows); | ||
} | ||
|
||
[Fact] | ||
public void SetRows_UpdateRows_WithListDimensionDataFields() | ||
{ | ||
// Arrange | ||
var mockRow = new Mock<IRows>(); | ||
mockRow.Setup(s => s.Rows).Returns(new List<DimensionColumn>() { new DimensionColumn() { DataField = new TextDataField("InitialField") } }); | ||
var visualization = mockRow.Object; | ||
|
||
var listFields = new List<DimensionDataField>(); | ||
var expectedRows = new List<DimensionColumn>(); | ||
|
||
var firstMockDimensionDataField = new Mock<DimensionDataField>("FirstFieldName"); | ||
var firstField = firstMockDimensionDataField.Object; | ||
expectedRows.Add(new DimensionColumn() { DataField = firstField }); | ||
listFields.Add(firstField); | ||
|
||
var secondMockDimensionDataField = new Mock<DimensionDataField>("SecondFieldName"); | ||
var secondField = secondMockDimensionDataField.Object; | ||
expectedRows.Add(new DimensionColumn() { DataField = secondField }); | ||
listFields.Add(secondField); | ||
|
||
// Act | ||
visualization.SetRows(listFields.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedRows, visualization.Rows); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ITabularColumnsExtensionsFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Moq; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class ITabularColumnsExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetColumns_UpdateColumns_WithListFieldNames() | ||
{ | ||
// Arrange | ||
var mockTabularColumn = new Mock<ITabularColumns>(); | ||
mockTabularColumn.SetupGet(s => s.Columns).Returns(new List<TabularColumn> { new TabularColumn("InitialColumn") }); | ||
var visualization = mockTabularColumn.Object; | ||
|
||
var fieldNames = new List<string> { "FirstField", "SecondField" }; | ||
var expectedColumns = fieldNames.Select(fieldName => new TabularColumn(fieldName)).ToList(); | ||
|
||
// Act | ||
visualization.SetColumns(fieldNames.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedColumns, visualization.Columns); | ||
} | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ITargetExtensionsFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using Moq; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class ITargetExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetTarget_UpdateTargets_WithFieldName() | ||
{ | ||
// Arrange | ||
var mockTarget = new Mock<ITargets>(); | ||
var targets = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField("InitialField") } }; | ||
mockTarget.Setup(s => s.Targets).Returns(targets); | ||
var targetObj = mockTarget.Object; | ||
|
||
var fieldName = "TestField"; | ||
var numberField = new NumberDataField(fieldName); | ||
var expectedTargetList = new List<MeasureColumn>() { new MeasureColumn() { DataField = numberField } }; | ||
|
||
// Act | ||
targetObj.SetTarget(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedTargetList, targetObj.Targets); | ||
} | ||
|
||
[Fact] | ||
public void SetTarget_UpdateTargets_WithNumberDataField() | ||
{ | ||
// Arrange | ||
var mockTarget = new Mock<ITargets>(); | ||
var targets = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField("InitialField") } }; | ||
mockTarget.Setup(s => s.Targets).Returns(targets); | ||
var targetObj = mockTarget.Object; | ||
|
||
var fieldName = "TestField"; | ||
var numberField = new NumberDataField(fieldName); | ||
var expectedTargetList = new List<MeasureColumn>() { new MeasureColumn() { DataField = numberField } }; | ||
|
||
// Act | ||
targetObj.SetTarget(numberField); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedTargetList, targetObj.Targets); | ||
} | ||
|
||
[Fact] | ||
public void SetTargets_UpdateTargets_WithListFieldNames() | ||
{ | ||
// Arrange | ||
var mockTarget = new Mock<ITargets>(); | ||
var targets = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField("InitialField") } }; | ||
mockTarget.Setup(s => s.Targets).Returns(targets); | ||
var targetObj = mockTarget.Object; | ||
|
||
var fieldNames = new List<string>() { "FirstField", "SecondField" }; | ||
var expectedTargetList = fieldNames.Select(fieldName => new MeasureColumn() | ||
{ | ||
DataField = new NumberDataField(fieldName) | ||
}); | ||
|
||
// Act | ||
targetObj.SetTargets(fieldNames.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedTargetList, targetObj.Targets); | ||
} | ||
|
||
[Fact] | ||
public void SetTargets_UpdateTargets_WithListNumberDataField() | ||
{ | ||
// Arrange | ||
var mockTarget = new Mock<ITargets>(); | ||
var targets = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField("InitialField") } }; | ||
mockTarget.Setup(s => s.Targets).Returns(targets); | ||
var targetObj = mockTarget.Object; | ||
|
||
var numberFields = new List<NumberDataField>() | ||
{ | ||
new NumberDataField("FirstField"), | ||
new NumberDataField("SecondField"), | ||
}; | ||
var expectedTargetList = numberFields.Select(field => new MeasureColumn() | ||
{ | ||
DataField = field | ||
}); | ||
|
||
// Act | ||
targetObj.SetTargets(numberFields.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedTargetList, targetObj.Targets); | ||
} | ||
} | ||
} |