-
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 'visualization/grid-pivot' of https://github.com/RevealB…
…i/Reveal.Sdk.Dom into visualization/grid-pivot
- Loading branch information
Showing
7 changed files
with
577 additions
and
0 deletions.
There are no files selected for viewing
155 changes: 155 additions & 0 deletions
155
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/IAxisExtensionsFixture.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,155 @@ | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class IAxisExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetXAxis_UpdateXAxis_WithFieldName() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fieldName = "TestFieldName"; | ||
var expectedXAxes = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField(fieldName) } }; | ||
|
||
// Act | ||
visualization.SetXAxis(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedXAxes, visualization.XAxes); | ||
} | ||
|
||
[Fact] | ||
public void SetXAxis_UpdateXAxis_WithNumberDataField() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fieldName = "TestFieldName"; | ||
var field = new NumberDataField(fieldName); | ||
var expectedXAxes = new List<MeasureColumn>() { new MeasureColumn() { DataField = field } }; | ||
|
||
// Act | ||
visualization.SetXAxis(field); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedXAxes, visualization.XAxes); | ||
} | ||
|
||
[Fact] | ||
public void SetXAxes_UpdateXAxis_WithListFieldNames() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fieldNames = new List<string>() | ||
{ | ||
"FirstFieldName", | ||
"SecondFieldName" | ||
}; | ||
var expectedXAxes = fieldNames.Select(fieldName => new MeasureColumn() { DataField = new NumberDataField(fieldName) }); | ||
|
||
// Act | ||
visualization.SetXAxes(fieldNames.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedXAxes, visualization.XAxes); | ||
} | ||
|
||
[Fact] | ||
public void SetXAxes_UpdateXAxis_WithListNumberDataFields() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fields = new List<NumberDataField>() | ||
{ | ||
new NumberDataField("FirstFieldName"), | ||
new NumberDataField("SecondFieldName") | ||
}; | ||
var expectedXAxes = fields.Select(x => new MeasureColumn() { DataField = x }); | ||
|
||
// Act | ||
visualization.SetXAxes(fields.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedXAxes, visualization.XAxes); | ||
} | ||
|
||
[Fact] | ||
public void SetYAxis_UpdateYAxis_WithFieldName() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fieldName = "TestFieldName"; | ||
var expectedYAxes = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField(fieldName) } }; | ||
|
||
// Act | ||
visualization.SetYAxis(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedYAxes, visualization.YAxes); | ||
} | ||
|
||
[Fact] | ||
public void SetYAxis_UpdateYAxis_WithNumberDataField() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fieldName = "TestFieldName"; | ||
var field = new NumberDataField(fieldName); | ||
var expectedYAxes = new List<MeasureColumn>() { new MeasureColumn() { DataField = field } }; | ||
|
||
// Act | ||
visualization.SetYAxis(field); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedYAxes, visualization.YAxes); | ||
} | ||
|
||
[Fact] | ||
public void SetYAxes_UpdateYAxis_WithListFieldNames() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fieldNames = new List<string>() | ||
{ | ||
"FirstFieldName", | ||
"SecondFieldName" | ||
}; | ||
var expectedYAxes = fieldNames.Select(fieldName => new MeasureColumn() { DataField = new NumberDataField(fieldName) }); | ||
|
||
// Act | ||
visualization.SetYAxes(fieldNames.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedYAxes, visualization.YAxes); | ||
} | ||
|
||
[Fact] | ||
public void SetYAxes_UpdateYAxis_WithListNumberDataFields() | ||
{ | ||
// Arrange | ||
var visualization = new MockIAxis(); | ||
var fields = new List<NumberDataField>() | ||
{ | ||
new NumberDataField("FirstFieldName"), | ||
new NumberDataField("SecondFieldName") | ||
}; | ||
var expectedYAxes = fields.Select(x => new MeasureColumn() { DataField = x }); | ||
|
||
// Act | ||
visualization.SetYAxes(fields.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedYAxes, visualization.YAxes); | ||
} | ||
|
||
private class MockIAxis : IAxis | ||
{ | ||
public List<MeasureColumn> XAxes { get; } = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField("InitialX") } }; | ||
|
||
public List<MeasureColumn> YAxes { get; } = new List<MeasureColumn>() { new MeasureColumn() { DataField = new NumberDataField("InitialY") } }; | ||
} | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoriesExtensionsFixture.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,99 @@ | ||
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 ICategoriesExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetCategory_UpdateCategories_WithFieldName() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategories(); | ||
var fieldName = "TestField"; | ||
var expectedCategories = new List<DimensionColumn> { | ||
new DimensionColumn() | ||
{ | ||
DataField = new TextDataField(fieldName), | ||
} | ||
}; | ||
|
||
// Act | ||
visualization.SetCategory(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategories, visualization.Categories); | ||
} | ||
|
||
[Fact] | ||
public void SetCategory_UpdateCategories_WithDimensionDataField() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategories(); | ||
var fieldName = "TestField"; | ||
var mockDimensionDataField = new Mock<DimensionDataField>(fieldName); | ||
var field = mockDimensionDataField.Object; | ||
var expectedCategories = new List<DimensionColumn> { | ||
new DimensionColumn() | ||
{ | ||
DataField = field, | ||
} | ||
}; | ||
|
||
// Act | ||
visualization.SetCategory(field); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategories, visualization.Categories); | ||
} | ||
|
||
[Fact] | ||
public void SetCategories_UpdateCategories_WithListFieldNames() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategories(); | ||
var fieldNames = new List<string> { "FirstFieldName", "SecondFieldName" }; | ||
var expectedCategories = fieldNames.Select(x => new DimensionColumn { DataField = new TextDataField(x) }); | ||
|
||
// Act | ||
visualization.SetCategories(fieldNames.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategories, visualization.Categories); | ||
} | ||
|
||
[Fact] | ||
public void SetCategories_UpdateCategories_WithListDimensionDataFields() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategories(); | ||
|
||
var fields = new List<DimensionDataField>(); | ||
var expectedCategories = new List<DimensionColumn>(); | ||
|
||
var mockDimensionDataField1 = new Mock<DimensionDataField>("FirstFieldName"); | ||
var f1 = mockDimensionDataField1.Object; | ||
fields.Add(f1); | ||
expectedCategories.Add(new DimensionColumn() { DataField = f1 }); | ||
|
||
var mockDimensionDataField2 = new Mock<DimensionDataField>("SecondFieldName"); | ||
var f2 = mockDimensionDataField2.Object; | ||
fields.Add(f2); | ||
expectedCategories.Add(new DimensionColumn() { DataField = f2 }); | ||
|
||
// Act | ||
visualization.SetCategories(fields.ToArray()); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategories, visualization.Categories); | ||
} | ||
|
||
private class MockICategories : ICategories | ||
{ | ||
public List<DimensionColumn> Categories { get; } = new List<DimensionColumn>(); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.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,52 @@ | ||
using Moq; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class ICategoryExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetCategory_UpdateCategory_WithFieldName() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategory(); | ||
var fieldName = "TestField"; | ||
var expectedCategory = new DimensionColumn() | ||
{ | ||
DataField = new TextDataField(fieldName) | ||
}; | ||
|
||
// Act | ||
visualization.SetCategory(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategory, visualization.Category); | ||
} | ||
|
||
[Fact] | ||
public void SetCategory_UpdateCategory_WithDimensionDataField() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategory(); | ||
var fieldName = "TestField"; | ||
var mockDimensionDataField = new Mock<DimensionDataField>(fieldName); | ||
var field = mockDimensionDataField.Object; | ||
var expectedCategory = new DimensionColumn() | ||
{ | ||
DataField = field | ||
}; | ||
|
||
// Act | ||
visualization.SetCategory(field); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategory, visualization.Category); | ||
} | ||
|
||
private class MockICategory : ICategory | ||
{ | ||
public DimensionColumn Category { get; set; } | ||
} | ||
} | ||
} |
Oops, something went wrong.