コード例 #1
0
ファイル: ContestTest.cs プロジェクト: sturuiz89/ActivEarth
        public void TestContestTeamScoreCalculation()
        {
            using (_trans)
            {
                Log("Creating group contest");
                int id = ContestManager.CreateContest(ContestType.Group, "Test Contest 1",
                    "This is a test time-based contest.", 50, DateTime.Now, DateTime.Now.AddDays(1),
                    Statistic.Steps);
                Contest contest = ContestManager.GetContest(id);

                Team team = new Team("Team1");
                team.Add(_group1.Members);
                team.Add(_group2.Members);

                Log("Adding four-member team to contest");
                contest.AddTeam(team);

                Log("Setting individual initial statistics");
                _user1.SetStatistic(Statistic.Steps, 0);
                _user2.SetStatistic(Statistic.Steps, 50);
                _user3.SetStatistic(Statistic.Steps, 100);
                _user4.SetStatistic(Statistic.Steps, 150);

                Log("Locking initial values");
                contest.LockInitialValues();

                Log("Adding 50 steps to each user");
                _user1.SetStatistic(Statistic.Steps, 50);
                _user2.SetStatistic(Statistic.Steps, 100);
                _user3.SetStatistic(Statistic.Steps, 150);
                _user4.SetStatistic(Statistic.Steps, 200);

                Log("Updating contest scores");
                contest.UpdateScores();

                Log("Verifying team aggregate score");
                Assert.AreEqual(200, contest.Teams[0].Score);
            }
        }
コード例 #2
0
ファイル: Contest.cs プロジェクト: sturuiz89/ActivEarth
        /// <summary>
        /// Adds a user to the Contest.
        /// </summary>
        /// <param name="user">User to be added.</param>
        public void AddUser(User user)
        {
            string teamName = String.Format("{0} {1}", user.FirstName, user.LastName);
            //TODO: Assert that no team with this name exists already

            Team newTeam = new Team(teamName);
            newTeam.Add(user);

            this.AddTeam(newTeam);
        }
コード例 #3
0
        public void TestGetTeamByTeamId()
        {
            using (_trans)
            {
                Log("Creating contest to put the team in");
                Contest contest = new Contest("Test Contest1", "This is a test contest",
                    30, ContestEndMode.GoalBased, ContestType.Group, DateTime.Today,
                    new EndCondition(500), Statistic.Steps);

                Log("Adding the contest to the DB");
                int contestId = ContestDAO.CreateNewContest(contest);

                Log("Creating team");
                Team team = new Team("Test Team");
                team.Add(new User("Test", "Subject1"));
                team.Add(new User("Test", "Subject2"));

                Log("Adding team to DB");
                int id = TeamDAO.CreateNewTeam(team, contestId);

                Log("Retrieving team from DB");
                Assert.IsNotNull(TeamDAO.GetTeamFromTeamId(id));

            }
        }