Prechádzať zdrojové kódy

Added basic games test case

Ronald Peterson 10 rokov pred
rodič
commit
ef8e330220
1 zmenil súbory, kde vykonal 33 pridanie a 0 odobranie
  1. 33 0
      games/games_test.go

+ 33 - 0
games/games_test.go

@@ -0,0 +1,33 @@
+	package games
+
+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)
+	}
+}