[gbrainy/gbrainy_15x] GameManager unit test
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy/gbrainy_15x] GameManager unit test
- Date: Tue, 11 May 2010 05:42:50 +0000 (UTC)
commit 5c73c7f93947bca4bf99bbcfea0f3041692a095e
Author: Jordi Mas <jmas softcatala org>
Date: Tue May 11 07:43:17 2010 +0200
GameManager unit test
tests/Core/GameManagerTest.cs | 77 +++++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 3 +-
2 files changed, 79 insertions(+), 1 deletions(-)
---
diff --git a/tests/Core/GameManagerTest.cs b/tests/Core/GameManagerTest.cs
new file mode 100644
index 0000000..b227e9b
--- /dev/null
+++ b/tests/Core/GameManagerTest.cs
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+
+using gbrainy.Core.Main;
+
+namespace gbrainyTest
+{
+ [TestFixture]
+ public class GameManagerTest
+ {
+ [TestFixtureSetUp]
+ public void Construct ()
+ {
+ Console.WriteLine ("GameManagerTest constructor");
+ }
+
+ //Lists the games without tip
+ public void GamesWithNoTip ()
+ {
+ int notip = 0;
+ GameManager manager = new GameManager ();
+
+ Type[] games = manager.CustomGames;
+
+ foreach (Type type in games)
+ {
+ Game game = (Game) Activator.CreateInstance (type, true);
+ if (game.TipString == String.Empty)
+ {
+ notip++;
+ //Console.WriteLine ("Game with no tip {0} - {1}", game.Name, game);
+ }
+ }
+ Console.WriteLine ("Games without tip: {0} ({1}%)", notip, notip * 100 / games.Length);
+ }
+
+ [Test]
+ public void GamesNoDuplicatedName ()
+ {
+ Dictionary <string, bool> dictionary;
+ GameManager manager = new GameManager ();
+ Type[] games = manager.CustomGames;
+
+ dictionary = new Dictionary <string, bool> (games.Length);
+
+ foreach (Type type in games)
+ {
+ Game game = (Game) Activator.CreateInstance (type, true);
+
+ Assert.AreEqual (false, dictionary.ContainsKey (game.Name),
+ String.Format ("Game name {0} is duplicated", game.Name));
+
+ dictionary.Add (game.Name, true);
+ }
+ }
+ }
+}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7eb57c3..3695e8e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,7 +9,8 @@ CSFILES = \
$(srcdir)/Core/AnalogiesFactoryTest.cs \
$(srcdir)/Core/PlayerHistoryTest.cs \
$(srcdir)/Core/PlayerPersonalRecordTest.cs \
- $(srcdir)/Core/GameSessionTest.cs
+ $(srcdir)/Core/GameSessionTest.cs \
+ $(srcdir)/Core/GameManagerTest.cs
ASSEMBLIES = \
$(NUNIT_LIBS) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]