Example #1
0
        public void TestCurrentActivityConstructor()
        {
            Activity testActivity = new Activity("John Doe", "Complete me", 3, 4, null);
            CurrentActivity currActivity = new CurrentActivity(testActivity);

            Assert.AreEqual(testActivity, currActivity.Activity);
            Assert.AreEqual(testActivity.Time, currActivity.TimeLeft);
        }
Example #2
0
        public void TestCompletedActivityConstructor()
        {
            Activity testActivity = new Activity("John Doe", "Complete me", 3, 4, null);
            ActivityGrade ag = ActivityGrade.Superb;
            string comment = "Was great!";

            CompletedActivity completedActivity = new CompletedActivity(testActivity, ag, comment);

            Assert.AreEqual(testActivity, completedActivity.Activity);
            Assert.AreEqual(ag, completedActivity.Grade);
            Assert.AreEqual(comment, completedActivity.Comment);
        }
Example #3
0
        /// <summary>
        /// Gives the user a new activity to perform. Can not already be doing an activity.
        /// </summary>
        /// <param name="newActivity">New activity to start with.</param>
        public void SetCurrentActivity(Activity newActivity)
        {
            // can not start a new activity before completing the old one
            if (CurrentActivity != null)
            {
                throw new AlreadyInActivityException("Already performing an activity.");
            }

            // new activity is set for the user
            CurrentActivity = new CurrentActivity(newActivity);
            string name = CurrentActivity.Activity.Name;
            Debug.WriteLine(name);
        }
Example #4
0
        public void TestSetCurrentActivityWhenTheUserHasNoCurrentActivity()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<MoodType> CuresMoods = new List<MoodType>();
            CuresMoods.Add(MoodType.Sad);
            Activity Activity = new Activity("test", "Check this out", 8, 25, CuresMoods);

            User.SetCurrentActivity(Activity);
            

            Assert.AreEqual(Activity, User.CurrentActivity.Activity);
            Assert.AreEqual(Activity.Time, User.CurrentActivity.TimeLeft);
        }
Example #5
0
        public void TestActivityConstructor()
        {
            string name = "John Doe";
            string description = "Complete me";
            int points = 5;
            int time = 4;
            List<MoodType> curesMoods = new List<MoodType>();
            curesMoods.Add(MoodType.Sad);
            curesMoods.Add(MoodType.Lonely);

            Activity testActivity = new Activity(name, description, points, time, curesMoods);

            Assert.AreEqual(name, testActivity.Name);
            Assert.AreEqual(description, testActivity.Description);
            Assert.AreEqual(points, testActivity.Points);
            Assert.AreEqual(time, testActivity.Time);
            Assert.AreEqual(curesMoods, testActivity.CuresMoods);
        }
Example #6
0
        /// <summary>
        /// Method for getting an Activity from the database.
        /// </summary>
        /// <param name="activity"></param>Name of the Activity.
        /// <returns></returns>Returns the Activity with the given name from param. 
        public Activity GetActivityQuery(String activity)
        {
            OpenConnection();

            string commandTextGetMoods = "SELECT moodType FROM GoodFor WHERE activityName = @Activity";
            var mySqlCommand = new MySqlCommand(commandTextGetMoods, Connection);
            mySqlCommand.Parameters.AddWithValue("@Activity", activity);
            var reader = mySqlCommand.ExecuteReader();
            List<string> moods = new List<string>();

            int i = 0;
            while (reader.Read())
            {
                moods.Add((String)reader.GetValue(i));
                i++;
            }

            CloseConnection();
            OpenConnection();

            string commandTextFromActivity = "SELECT * FROM Activity WHERE Name = @Activity2";
            var mySqlCommand2 = new MySqlCommand(commandTextFromActivity, Connection);
            mySqlCommand2.Parameters.AddWithValue("@Activity2", activity);
            var reader2 = mySqlCommand2.ExecuteReader();
            Activity a = null;

            if (reader2.Read())
            {
                a = new Activity("" + reader2.GetString(0), "" + reader2.GetString(1), reader2.GetInt16(2), reader2.GetInt16(3), moods);
            }
            CloseConnection();
            return a;
        }
Example #7
0
        public void TestTotalPoints()
        {
            string UserName = "******";
            User User = new User(UserName);
            User.AddMood(MoodType.Sad);
            List<MoodType> CuresMoods = new List<MoodType>();
            CuresMoods.Add(MoodType.Sad);
            Activity Activity = new Activity("test", "Check this out", 8, 0, CuresMoods);
            CurrentActivity CurrentActivity = new CurrentActivity(Activity);

            List<Trophy> TrophyList = User.CompleteActivity(CurrentActivity, ActivityGrade.Good, "Need more time");
            Assert.AreEqual(8, User.TotalPoints());
        }
Example #8
0
        public void TestCompleteActivityWithTimeLeft()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<MoodType> CuresMoods = new List<MoodType>();
            CuresMoods.Add(MoodType.Sad);
            Activity Activity = new Activity("test", "Check this out", 8, 3, CuresMoods);
            CurrentActivity CurrentActivity = new CurrentActivity(Activity);

            List<Trophy> TrophyList = User.CompleteActivity(CurrentActivity, ActivityGrade.Good, "Need more time");

            Assert.AreEqual(0, TrophyList.Count);
        }
Example #9
0
        public void TestCompleteCurrentActivity()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<MoodType> CuresMoods = new List<MoodType>();
            CuresMoods.Add(MoodType.Sad);
            Activity Activity = new Activity("test", "Check this out", 8, 25, CuresMoods);

            User.SetCurrentActivity(Activity);
            Assert.AreEqual(0, User.CompleteCurrentActivity(ActivityGrade.Good, "Like!").Count);
        }
Example #10
0
        public void TestDropCurrentActivity()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<MoodType> CuresMoods = new List<MoodType>();
            CuresMoods.Add(MoodType.Sad);
            Activity Activity = new Activity("test", "Check this out", 8, 25, CuresMoods);

            User.SetCurrentActivity(Activity);
            User.DropCurrentActivity();

            Assert.AreEqual(null, User.CurrentActivity);
        }
Example #11
0
 /// <summary>
 /// Construct a completed activity with its fields.
 /// </summary>
 /// <param name="activity">The completed activity.</param>
 /// <param name="grade">The grade that was given.</param>
 /// <param name="comment">The comment that was given. It is optional, can be null.</param>
 public CompletedActivity(Activity activity, ActivityGrade grade, string comment)
 {
     Activity = activity;
     Grade = grade;
     Comment = (comment == null) ? "" : comment;
 }