From b9f16ac108f3a4020fc6b454f943619b291d82be Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 23 Dec 2024 10:30:52 +0700 Subject: [PATCH 1/2] Create unit tests for ICategoryExtensions class --- .../Extensions/ICategoryExtensionsFixture.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs 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 0000000..47aded5 --- /dev/null +++ b/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs @@ -0,0 +1,58 @@ +using Moq; +using Reveal.Sdk.Dom.Visualizations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +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; } + } + } +} From d0ab5f0977736c276115895126e97823e09b7020 Mon Sep 17 00:00:00 2001 From: Viktor Date: Mon, 23 Dec 2024 10:31:58 +0700 Subject: [PATCH 2/2] Remove unused codes --- .../Visualizations/Extensions/ICategoryExtensionsFixture.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs b/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs index 47aded5..96f2b9c 100644 --- a/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.cs @@ -1,11 +1,5 @@ using Moq; using Reveal.Sdk.Dom.Visualizations; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions