Skip to content

[3pts] Implement SqliteGameRepository #16

@github-actions

Description

@github-actions

Description

Implement IGameRepository interface using SQLite database for persistence.

Depends on: IGameRepository interface issue

SqliteGameRepository Class

Implements IGameRepository using Microsoft.Data.Sqlite

Database Operations

SaveGame(GameState state)

  • Upserts game save by player name
  • Creates tables if they don't exist

LoadGame(string playerName)

  • Returns GameState if found
  • Returns null if not found

SaveScore(string playerName, int score)

  • Inserts new leaderboard entry
  • Includes timestamp

GetLeaderboard()

  • Returns top 10 scores
  • Ordered by score descending
  • Includes player name, score, and date

Requirements

  • Creates database and tables on first run
  • Use 'using' statements for connection disposal
  • Proper SQL parameterization to prevent injection
  • Database file: classcrawler.db

Acceptance Criteria

  • SqliteGameRepository class implements IGameRepository
  • Uses Microsoft.Data.Sqlite package
  • Creates database and tables on first run
  • SaveGame(GameState) upserts by player name
  • LoadGame(string playerName) returns GameState or null
  • SaveScore(string playerName, int score) inserts with timestamp
  • GetLeaderboard() returns top 10 scores descending
  • Uses 'using' statements for proper disposal
  • SQL uses parameters (no injection vulnerabilities)
  • Class documented with XML comments

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions