Skip to content

Add unit tests for SystemTray.Linux (0% → 80%+ coverage) #6

Description

@Olbrasoft

Summary

SystemTray.Linux has no unit tests. Test project exists but contains only empty placeholder test.

Problem

  • Current state: 0% test coverage
  • Impact: No safety net for refactoring, regressions not caught, violates quality standards
  • Target: 80%+ coverage for business logic (per refactoring guide)

Proposed Solution

Add comprehensive unit tests for all public APIs:

Priority 1 - Core functionality (Target: 90%+)

  • TrayIconManager - create/get/remove icons
  • TrayIcon - initialize, set icon, show/hide, dispose
  • IconRenderer - render, cache, pre-cache

Priority 2 - Animation & State (Target: 85%+)

  • TrayIcon.StartAnimation / StopAnimation
  • TrayIcon.SetIcon with different states
  • Icon state transitions

Priority 3 - Internal (Target: 70%+)

  • StatusNotifierItemHandler - D-Bus message handling

Test Strategy

  • Use Moq for ILogger, IIconRenderer mocking
  • Integration tests for D-Bus communication (may need separate project)
  • Test error handling (null params, disposed objects, file not found)

Files Affected

  • tests/SystemTray.Linux.Tests/ - add new test files:
    • TrayIconManagerTests.cs
    • TrayIconTests.cs
    • IconRendererTests.cs
    • StatusNotifierItemHandlerTests.cs

Acceptance Criteria

  • 80%+ code coverage for business logic
  • All public methods have tests
  • Edge cases covered (null, disposed, errors)
  • Tests follow naming convention: MethodName_Scenario_ExpectedResult
  • Remove placeholder UnitTest1.cs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions