Beispiel #1
0
        public void Update()
        {
            MatchDao MatchDao = new MatchDao(database);

            TestPlayerDao pdao = new TestPlayerDao();
            TournamentDao td   = new TournamentDao(database);
            var           list = td.FindAll();
            int           tId  = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);

            int id = MatchDao.Insert(m);

            Assert.IsNotNull(id);

            Match n = MatchDao.FindById(id);

            n.Finished = true;
            MatchDao.Update(n);

            Assert.IsTrue(MatchDao.FindById(id).Finished);
        }
Beispiel #2
0
        public void InsertMatchs()
        {
            MatchDao MatchDao = new MatchDao(database);

            TestPlayerDao pdao = new TestPlayerDao();
            TournamentDao td   = new TournamentDao(database);
            var           list = td.FindAll();
            int           tId  = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);


            int stat1 = MatchDao.FindAll().Count;

            MatchDao.Insert(m);
            int stat2 = MatchDao.FindAll().Count;

            Assert.IsTrue(stat1 == stat2 - 1);
        }
Beispiel #3
0
        public void GetOneMatchByID()
        {
            MatchDao      MatchDao = new MatchDao(database);
            TestPlayerDao pdao     = new TestPlayerDao();
            TournamentDao td       = new TournamentDao(database);
            var           list     = td.FindAll();
            int           tId      = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);

            int retValue = MatchDao.Insert(m);

            Match match = MatchDao.FindById(retValue);

            Assert.AreEqual(match.Team1Player1, p1id);
            Assert.AreEqual(match.Team1Player2, p2id);
            Assert.AreEqual(match.Team2Player1, p3id);
            Assert.AreEqual(match.Team2Player2, p4id);
            Assert.AreEqual(match.TournamentId, tId);
            Assert.IsNull(m.ResultPointsPlayer1);
            Assert.IsNull(m.ResultPointsPlayer2);
        }
Beispiel #4
0
        public void TestMatchContructor()
        {
            TestPlayerDao pdao = new TestPlayerDao();
            TournamentDao td   = new TournamentDao(database);
            var           list = td.FindAll();
            int           tId  = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);

            Assert.AreEqual(p1id, m.Team1Player1);
            Assert.AreEqual(p2id, m.Team1Player2);
            Assert.AreEqual(p3id, m.Team2Player1);
            Assert.AreEqual(p4id, m.Team2Player2);
            Assert.AreEqual(tId, m.TournamentId);
            Assert.IsNull(m.ResultPointsPlayer1);
            Assert.IsNull(m.ResultPointsPlayer2);
        }
Beispiel #5
0
        public void CheckDeleteById()
        {
            MatchDao      MatchDao = new MatchDao(database);
            TestPlayerDao pdao     = new TestPlayerDao();
            TournamentDao td       = new TournamentDao(database);
            var           list     = td.FindAll();
            int           tId      = list[0].ID;

            PlayerDao pd    = new PlayerDao(database);
            var       plist = pd.FindAll();

            int p1id = plist[0].ID;
            int p2id = plist[1].ID;
            int p3id = plist[2].ID;
            int p4id = plist[3].ID;

            Match m = new Match(p1id, p2id, p3id, p4id, tId, false);

            int id = MatchDao.Insert(m);

            int stat1 = MatchDao.FindAll().Count;

            MatchDao.DeleteById(id);
            int stat2 = MatchDao.FindAll().Count;


            Assert.AreEqual(stat1, stat2 + 1);
        }