Files
Sharepoint-Toolbox/.planning/phases/09-storage-visualization/09-04-SUMMARY.md
Dev 713cf91d00 docs(09-04): complete StorageViewModel chart unit tests plan
- SUMMARY.md with 7 passing tests documented
- STATE.md updated to plan 4/4, phase 9 complete
- ROADMAP.md phase 09 marked complete

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 15:41:55 +02:00

3.2 KiB

phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
phase plan subsystem tags dependency_graph tech_stack key_files decisions metrics
09-storage-visualization 04 storage-visualization
tests
unit-tests
charts
viewmodel
xunit
requires provides affects
09-03
chart-unit-tests
SharepointToolbox.Tests
added patterns
reflection-based-property-setting
moq-service-mocking
created modified
SharepointToolbox.Tests/ViewModels/StorageViewModelChartTests.cs
SharepointToolbox.Tests/SharepointToolbox.Tests.csproj
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:

  1. After_setting_metrics_HasChartData_is_true_and_PieChartSeries_has_entries -- Sets 5 metrics, asserts HasChartData=true and PieChartSeries count=5
  2. After_setting_metrics_BarChartSeries_has_one_ColumnSeries_with_matching_values -- Verifies single ColumnSeries with value count matching metric count
  3. Toggle_IsDonutChart_changes_PieChartSeries_InnerRadius -- Asserts InnerRadius=50 when donut, 0 when toggled off
  4. More_than_10_metrics_produces_11_series_entries_with_Other -- 15 metrics produce 10+1 "OTHER" entries in pie, bar, and x-axis labels
  5. Ten_or_fewer_metrics_produces_no_Other_entry -- 10 metrics produce exactly 10 entries, no "OTHER"
  6. OnTenantSwitched_clears_FileTypeMetrics_and_HasChartData_is_false -- TenantSwitchedMessage clears all chart state
  7. 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)
  • Fix: Changed assertions to expect "OTHER"
  • Files modified: StorageViewModelChartTests.cs
  • Commit: 712b949

Verification

  • All 7 chart tests pass
  • Full suite: 210 passed, 22 skipped, 0 failed -- no regressions

Commits

Hash Message
712b949 test(09-04): add StorageViewModel chart unit tests

Self-Check: PASSED