Ejemplo n.º 1
0
        /// <summary>
        /// Sets the current challenge, if there already is one then throws AlreadyInAChallengeException.
        /// </summary>
        /// <param name="newChallenge">Which challenge to undertake for the user.</param>
        public void SetCurrentChallenge(Challenge challenge)
        {
            // can not start a new challenge before completing the old one

            if (connectToDatabase.onGoingChallenge(Username))
            {
                CurrentChallenge = new CurrentChallenge(challenge);
            }

            // new challenge is set for the user
            else
            {
                if (connectToDatabase.setCurrentChallenge(Username, challenge.Name))
                {
                    Debug.WriteLine("connectToDatabase.setCurrentChallenge(Username,challenge.Name); has run.");
                    CurrentChallenge = new CurrentChallenge(challenge);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the current challenge, if there already is one then throws AlreadyInAChallengeException.
        /// </summary>
        /// <param name="newChallenge">Which challenge to undertake for the user.</param>
        public void SetCurrentChallenge(Challenge challenge)
        {

            // can not start a new challenge before completing the old one
            
            if (connectToDatabase.onGoingChallenge(Username))
            {
                CurrentChallenge = new CurrentChallenge(challenge);
            }
            
            // new challenge is set for the user
            else
            {
                if (connectToDatabase.setCurrentChallenge(Username, challenge.Name))
                {
                    Debug.WriteLine("connectToDatabase.setCurrentChallenge(Username,challenge.Name); has run.");
                    CurrentChallenge = new CurrentChallenge(challenge);
                }
            }
        }
Ejemplo n.º 3
0
 public void TestCurrentChallangeConstructorWithNullParameter()
 {
     CurrentChallenge CurrentChallange = new CurrentChallenge(null);
 }
Ejemplo n.º 4
0
        public void TestCurrentChallangeConstructorWithValidParameter()
        {
            List<Activity> requirements = new List<Activity>();
            requirements.Add(new Activity("John Doe", "Complete me", 3, 4, null));
            Challenge challenge = new Challenge("test", "test", new Time(0, 0, 0), new Time(1, 0, 0), requirements);
            CurrentChallenge currentChallange = new CurrentChallenge(challenge);

            DateTime now = DateTime.Now;

            Assert.AreEqual(challenge, currentChallange.Challenge);
        }