Used reflection to set FileTypeMetrics (private setter) instead of mocking full RunOperationAsync flow -- avoids sealed ClientContext dependency
Added LiveChartsCore.SkiaSharpView.WPF 2.0.0-rc5.4 to test project to match main project version
Asserted against DisplayLabel-uppercased 'OTHER' not raw 'Other' to match FileTypeMetric.DisplayLabel behavior
duration
completed
146s
2026-04-07
Phase 09 Plan 04: StorageViewModel Chart Unit Tests Summary
7 xUnit tests verifying chart series computation from FileTypeMetrics, donut/bar toggle via InnerRadius, top-10+Other aggregation, tenant switch cleanup, and empty data edge case -- all without SharePoint connection.
What Was Done
Task 1: Create StorageViewModel chart unit tests (TDD)
Created StorageViewModelChartTests.cs with 7 tests:
After_setting_metrics_HasChartData_is_true_and_PieChartSeries_has_entries -- Sets 5 metrics, asserts HasChartData=true and PieChartSeries count=5
After_setting_metrics_BarChartSeries_has_one_ColumnSeries_with_matching_values -- Verifies single ColumnSeries with value count matching metric count
Toggle_IsDonutChart_changes_PieChartSeries_InnerRadius -- Asserts InnerRadius=50 when donut, 0 when toggled off
More_than_10_metrics_produces_11_series_entries_with_Other -- 15 metrics produce 10+1 "OTHER" entries in pie, bar, and x-axis labels
Ten_or_fewer_metrics_produces_no_Other_entry -- 10 metrics produce exactly 10 entries, no "OTHER"
OnTenantSwitched_clears_FileTypeMetrics_and_HasChartData_is_false -- TenantSwitchedMessage clears all chart state
Empty_metrics_yields_HasChartData_false_and_empty_series -- Empty input produces empty series and false HasChartData
Approach: Uses reflection to set FileTypeMetrics property (private setter triggers UpdateChartSeries internally), bypassing the need to mock sealed ClientContext for RunOperationAsync.
NuGet: Added LiveChartsCore.SkiaSharpView.WPF 2.0.0-rc5.4 to test project (matching main project version) for PieSeries<T>, ColumnSeries<T> type assertions.
Deviations from Plan
Auto-fixed Issues
1. [Rule 1 - Bug] "Other" series name uses DisplayLabel not raw extension
Found during: TDD RED phase
Issue: Test asserted Name == "Other" but FileTypeMetric("Other", ...).DisplayLabel returns "OTHER" (ToUpperInvariant)