| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package game
- import (
- "testing"
- )
- func TestAddGame(t *testing.T) {
- game := NewGame(100,100)
- games := New()
- games.AddGame(game)
- if len(games.ListGames()) != 1 {
- t.Fatalf("Incorrect ListGames size expeciting 1 got %v", len(games.ListGames()))
- }
- }
- func TestAdd2Games(t *testing.T) {
- game := NewGame(100,100)
- game2 := NewGame(100,100)
- games := New()
- games.AddGame(game)
- games.AddGame(game2)
- if len(games.ListGames()) != 2 {
- t.Fatalf("Incorrect ListGames size expeciting 2 got %v", len(games.ListGames()))
- }
- if games.ListGames()[0].Id != game.Id {
- t.Fatalf("Incorrect gameid expected %v got %v", games.ListGames()[0].Id, game.Id)
- }
- }
- func TestAddGetGame(t *testing.T) {
- game := NewGame(100,100)
- game2 := NewGame(100,100)
- game3 := NewGame(100,100)
- games := New()
- games.AddGame(game)
- games.AddGame(game2)
- games.AddGame(game3)
- resultGame := games.GetGame(game2.Id)
- if resultGame.Id != game2.Id {
- t.Fatalf("Incorrect ListGames size expeciting %v got %v", resultGame.Id, game2.Id)
- }
- }
|