|
| 1 | +using Syncfusion.Maui.Toolkit.Charts; |
| 2 | + |
| 3 | +namespace Syncfusion.Maui.Toolkit.UnitTest.Charts |
| 4 | +{ |
| 5 | + public class PolarAreaSegmentCapacityUnitTests : BaseUnitTest |
| 6 | + { |
| 7 | + #region PolarAreaSegment List Capacity Tests |
| 8 | + |
| 9 | + [Fact] |
| 10 | + public void PolarAreaSeries_WithDataPoints_RendersCorrectly() |
| 11 | + { |
| 12 | + // Arrange - create a polar chart with area series to exercise the |
| 13 | + // GenerateInteriorPoints and GenerateStrokePoints methods |
| 14 | + var chart = new SfPolarChart(); |
| 15 | + var series = new PolarAreaSeries |
| 16 | + { |
| 17 | + ItemsSource = new List<PolarDataModel> |
| 18 | + { |
| 19 | + new() { Direction = "N", Speed = 10 }, |
| 20 | + new() { Direction = "NE", Speed = 20 }, |
| 21 | + new() { Direction = "E", Speed = 15 }, |
| 22 | + new() { Direction = "SE", Speed = 25 }, |
| 23 | + new() { Direction = "S", Speed = 12 }, |
| 24 | + }, |
| 25 | + XBindingPath = "Direction", |
| 26 | + YBindingPath = "Speed" |
| 27 | + }; |
| 28 | + |
| 29 | + chart.Series.Add(series); |
| 30 | + |
| 31 | + // Act - verify that the series can be created without throwing |
| 32 | + Assert.NotNull(series); |
| 33 | + Assert.Equal(5, ((IList<PolarDataModel>)series.ItemsSource).Count); |
| 34 | + } |
| 35 | + |
| 36 | + [Fact] |
| 37 | + public void PolarAreaSeries_EmptyDataSource_DoesNotThrow() |
| 38 | + { |
| 39 | + // Arrange |
| 40 | + var series = new PolarAreaSeries |
| 41 | + { |
| 42 | + ItemsSource = new List<PolarDataModel>(), |
| 43 | + XBindingPath = "Direction", |
| 44 | + YBindingPath = "Speed" |
| 45 | + }; |
| 46 | + |
| 47 | + // Act & Assert - no exception |
| 48 | + Assert.NotNull(series); |
| 49 | + Assert.Empty((IList<PolarDataModel>)series.ItemsSource); |
| 50 | + } |
| 51 | + |
| 52 | + [Fact] |
| 53 | + public void PolarAreaSeries_WithStroke_CreatesCorrectly() |
| 54 | + { |
| 55 | + // Arrange |
| 56 | + var series = new PolarAreaSeries |
| 57 | + { |
| 58 | + ItemsSource = new List<PolarDataModel> |
| 59 | + { |
| 60 | + new() { Direction = "N", Speed = 10 }, |
| 61 | + new() { Direction = "E", Speed = 20 }, |
| 62 | + new() { Direction = "S", Speed = 15 }, |
| 63 | + }, |
| 64 | + XBindingPath = "Direction", |
| 65 | + YBindingPath = "Speed", |
| 66 | + StrokeWidth = 2 |
| 67 | + }; |
| 68 | + |
| 69 | + // Act & Assert - stroke width set correctly |
| 70 | + Assert.Equal(2, series.StrokeWidth); |
| 71 | + } |
| 72 | + |
| 73 | + #endregion |
| 74 | + |
| 75 | + #region Helper |
| 76 | + |
| 77 | + class PolarDataModel |
| 78 | + { |
| 79 | + public string Direction { get; set; } = string.Empty; |
| 80 | + public double Speed { get; set; } |
| 81 | + } |
| 82 | + |
| 83 | + #endregion |
| 84 | + } |
| 85 | +} |
0 commit comments