Ejemplo n.º 1
0
        public void test_SelectBetweenTeams()
        {
            /* Test with test data , kärpät, tps and tappara. Function should
             * returns all rows which contain only teams from parameter list (=6). */
            List <string> teams = new List <string>();

            teams.Add("Kärpät");
            teams.Add("Tappara");
            teams.Add("TPS");

            MatchQuery mq = new MatchQuery();

            mq.addSubQuery(db.SelectBetweenTeams(teams));
            List <Match> rows = db.QueryMatches(mq.getQueryString());

            Assert.AreEqual(6, rows.Count);

            teams.Clear();
            teams.Add("TPS");
            teams.Add("TPS");
            teams.Add("TPS");

            mq.clearSubQueries();
            mq.addSubQuery(db.SelectBetweenTeams(teams));
            rows = db.QueryMatches(mq.getQueryString());
            Assert.AreEqual(0, rows.Count);
        }
Ejemplo n.º 2
0
        public void test_clearSubQueries()
        {
            MatchQuery mq = new MatchQuery();

            mq.addSubQuery("test");
            mq.clearSubQueries();
            Assert.AreEqual(0, mq.get_sub_queries().Count);
        }
Ejemplo n.º 3
0
        public void test_SelectWhereGD_GD_0()
        {
            MatchQuery mq = new MatchQuery();

            mq.addSubQuery(db.SelectWhereGD(0, false));
            List <Match> matches = db.QueryMatches(mq.getQueryString());

            Assert.AreEqual(0, matches.Count);
            mq.clearSubQueries();
            mq.addSubQuery(db.SelectWhereGD(0, true));
            matches = db.QueryMatches(mq.getQueryString());
            Assert.AreEqual(18, matches.Count);
        }
Ejemplo n.º 4
0
        public void test_SelectWhereGD_GD_negative()
        {
            /*negative goal difference is changed to 0, so test results should be equal
             * to test_SelectWhereGD_GD_0().*/
            MatchQuery mq = new MatchQuery();

            mq.addSubQuery(db.SelectWhereGD(-1, false));
            List <Match> matches = db.QueryMatches(mq.getQueryString());

            Assert.AreEqual(0, matches.Count);
            mq.clearSubQueries();
            mq.addSubQuery(db.SelectWhereGD(-2, true));
            matches = db.QueryMatches(mq.getQueryString());
            Assert.AreEqual(18, matches.Count);
        }
Ejemplo n.º 5
0
        public void test_SelectBetweenTeamsFromSeasons()
        {
            MatchQuery    mq    = new MatchQuery();
            List <string> teams = new List <string>()
            {
                "Kärpät", "Tappara"
            };
            List <string> seasons = new List <string>()
            {
                "16-17"
            };

            mq.addSubQuery(db.SelectBetweenTeamsFromSeasons(teams, seasons));
            List <Match> matches = db.QueryMatches(mq.getQueryString());

            Assert.AreEqual(2, matches.Count);

            seasons.RemoveAt(0);
            mq.clearSubQueries();
            mq.addSubQuery(db.SelectBetweenTeamsFromSeasons(teams, seasons));
            matches = db.QueryMatches(mq.getQueryString());
            Assert.AreEqual(4, matches.Count);
        }
Ejemplo n.º 6
0
        public void test_SelectBeforeOrAfterDate_teamOverload()
        {
            /* 1. Test with incorrect date format, should throw DateConversionError
             * 2. Test with a list of Kärpät, Kärpät after date '2017/03/25'.
             *      Should return 2 matches.
             * 3. Test with list of Kärpät, Kärpät, TPS after date '2017-03-25.
             *      Should return 3 matches.'*/
            List <string> teams = new List <string>()
            {
                "Kärpät", "Kärpät"
            };
            MatchQuery mq = new MatchQuery();

            mq.addSubQuery(db.SelectBeforeOrAfterDate(teams, "2017/03/25", true));
            List <Match> rows = db.QueryMatches(mq.getQueryString());

            Assert.AreEqual(2, rows.Count);

            teams.Add("TPS");
            mq.clearSubQueries();
            mq.addSubQuery(db.SelectBeforeOrAfterDate(teams, "2017-03-25", true));
            rows = db.QueryMatches(mq.getQueryString());
            Assert.AreEqual(3, rows.Count);
        }