diff --git a/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs b/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs new file mode 100644 index 00000000..96f2b9c2 --- /dev/null +++ b/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs @@ -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(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; } + } + } +}