-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make DrawChart public static; add _SharedPropertiesTests
Changed DrawChart method in ChangingPaintTasks to public static for external access. Added _SharedPropertiesTests class with Visibility and VisibilityAndPaintsTasks tests to verify chart rendering and drawable count behavior. Imported necessary namespaces for testing.
- Loading branch information
1 parent
b4c9c7d
commit d08b62e
Showing
2 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
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
80 changes: 80 additions & 0 deletions
80
tests/LiveChartsCore.UnitTesting/SeriesTests/_SharedPropertiesTests.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,80 @@ | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Specialized; | ||
using LiveChartsCore.Defaults; | ||
using LiveChartsCore.SkiaSharpView; | ||
using LiveChartsCore.SkiaSharpView.SKCharts; | ||
using LiveChartsCore.UnitTesting.CoreObjectsTests; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace LiveChartsCore.UnitTesting.SeriesTests; | ||
|
||
[TestClass] | ||
public class _SharedPropertiesTests | ||
{ | ||
[TestMethod] | ||
public void Visibility() | ||
{ | ||
var values = new ObservableCollection<ObservableValue>(); | ||
var lineSeries = new LineSeries<ObservableValue>(values); | ||
|
||
var chart = new SKCartesianChart | ||
{ | ||
Series = [lineSeries], | ||
Width = 1000, | ||
Height = 1000 | ||
}; | ||
|
||
_ = chart.GetImage(); | ||
|
||
var changes = 0; | ||
|
||
values.CollectionChanged += | ||
(object? sender, NotifyCollectionChangedEventArgs e) => | ||
Check warning on line 32 in tests/LiveChartsCore.UnitTesting/SeriesTests/_SharedPropertiesTests.cs GitHub Actions / Analyze (csharp, x86)
Check warning on line 32 in tests/LiveChartsCore.UnitTesting/SeriesTests/_SharedPropertiesTests.cs GitHub Actions / Analyze (csharp, x86)
Check warning on line 32 in tests/LiveChartsCore.UnitTesting/SeriesTests/_SharedPropertiesTests.cs GitHub Actions / Analyze (csharp, x64)
|
||
changes++; | ||
|
||
values.Add(new(1)); | ||
_ = chart.GetImage(); | ||
|
||
Assert.IsTrue(changes == 1); | ||
|
||
lineSeries.IsVisible = false; | ||
_ = chart.GetImage(); | ||
|
||
lineSeries.IsVisible = true; | ||
_ = chart.GetImage(); | ||
|
||
values.Add(new(1)); | ||
_ = chart.GetImage(); | ||
|
||
Assert.IsTrue(changes == 2); | ||
} | ||
|
||
[TestMethod] | ||
public void VisbilityAndPaintsTasks() | ||
{ | ||
var values = new ObservableCollection<DateTimePoint>() { new() }; | ||
var lineSeries = new ColumnSeries<DateTimePoint>(values); | ||
var chart = new SKCartesianChart | ||
{ | ||
Series = [lineSeries], | ||
Width = 1000, | ||
Height = 1000 | ||
}; | ||
|
||
_ = ChangingPaintTasks.DrawChart(chart, true); | ||
|
||
var canvas = chart.CoreCanvas; | ||
var drawables = canvas.DrawablesCount; | ||
var geometries = canvas.CountGeometries(); | ||
|
||
lineSeries.IsVisible = false; | ||
_ = ChangingPaintTasks.DrawChart(chart, true); | ||
|
||
lineSeries.IsVisible = true; | ||
_ = ChangingPaintTasks.DrawChart(chart, true); | ||
|
||
Assert.IsTrue( | ||
drawables == canvas.DrawablesCount && | ||
geometries == canvas.CountGeometries()); | ||
} | ||
} |