games_test.go 664 B

123456789101112131415161718192021222324252627282930313233
  1. package games
  2. import (
  3. "testing"
  4. )
  5. func TestAddGame(t *testing.T) {
  6. game := NewGame(100,100)
  7. games := New()
  8. games.AddGame(game)
  9. if len(games.ListGames()) != 1 {
  10. t.Fatalf("Incorrect ListGames size expeciting 1 got %v", len(games.ListGames()))
  11. }
  12. }
  13. func TestAdd2Games(t *testing.T) {
  14. game := NewGame(100,100)
  15. game2 := NewGame(100,100)
  16. games := New()
  17. games.AddGame(game)
  18. games.AddGame(game2)
  19. if len(games.ListGames()) != 2 {
  20. t.Fatalf("Incorrect ListGames size expeciting 2 got %v", len(games.ListGames()))
  21. }
  22. if games.ListGames()[0].Id != game.Id {
  23. t.Fatalf("Incorrect gameid expected %v got %v", games.ListGames()[0].Id, game.Id)
  24. }
  25. }