Exemplo n.º 1
0
        public void TestUserConstructor()
        {
            string UserName = "******";
            User User = new User(UserName);

            Assert.AreEqual(UserName, User.Username);
        }
Exemplo n.º 2
0
        public Presenter(MainForm view, User user)
        {
            connectToDatabase = new ConnectToDatabase("halso_hub");
            this.user = user;
            this.view = view;
            moodButtonState = 0;
            view.setPresenter(this);
            setupGUI();

			if (connectToDatabase.onGoingChallenge(user.Username) == true)
            {
                ChallengeActivitiesLeftInCurrentChallenge();
                StartChallengeButtonPressed();
                view.HideChallengesDisplayed();
                view.ShowActivitiesForChallenge();

				currentChallengeHover = connectToDatabase.GetCurrentChallenge(user.Username);
				Challenge startedChallenge = user.GetChallengeQuery(currentChallengeHover);

                if (startedChallenge != null && challengeSelected == false)
				{
					challengeSelected = true;
                    user.SetCurrentChallenge(startedChallenge);
                }

				view.ChangeChallengeDescriptionAndLabel(startedChallenge.Name, startedChallenge.Description);
			}
			else
			{
				GetAndShowChallenges();
			}
        }
Exemplo n.º 3
0
        public void TestAddMood()
        {
            MoodType Mood = MoodType.Lonely;
            string UserName = "******";
            User User = new User(UserName);

            Assert.AreEqual(0, User.CurrentMood.Count);

            User.AddMood(Mood);

            Assert.AreEqual(true, User.CurrentMood.Contains(Mood));
            Assert.AreEqual(1, User.CurrentMood.Count);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        static void Main(String[] args)
        {
            if (args.Length > 0)
            {
                MessageBox.Show("" + args[0]);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm MainForm = new MainForm();
            User user = new User("Mattias");
            Presenter presenter = new Presenter(MainForm, user);
            Application.Run(MainForm);
        }
Exemplo n.º 6
0
        public void TestPresenterConstructor()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            // Constructor
            Assert.AreEqual(pres, View.p);

            // stopAndHideTimer
            Assert.AreEqual(true, View.timerHidden);

            // updateMoodButtons
            Assert.AreEqual("VerySad", View.one);
            Assert.AreEqual("Sad", View.two);
            Assert.AreEqual("Happy", View.three);
            Assert.AreEqual("VeryHappy", View.four);
            Assert.AreEqual("How do you feel?", View.title);

            // showAllMoodButtons
            Assert.AreEqual(true, View.showAllMoodButtonsFlag);
        }
Exemplo n.º 7
0
        public void TestMoodButtonPressed()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            pres.moodButtonPressed("Sad");
            Assert.AreEqual("VeryTierd", View.one);
            Assert.AreEqual("Tired", View.two);
            Assert.AreEqual("Energetic", View.three);
            Assert.AreEqual("VeryEnergetic", View.four);
            Assert.AreEqual("How do you feel?", View.title);

            pres.moodButtonPressed("Tired");
            Assert.AreEqual("VeryStressed", View.one);
            Assert.AreEqual("Stressed", View.two);
            Assert.AreEqual("Calm", View.three);
            Assert.AreEqual("VeryCalm", View.four);
            Assert.AreEqual("How do you feel?", View.title);

            pres.moodButtonPressed("Stressed");
            Assert.AreEqual("VeryLonely", View.one);
            Assert.AreEqual("Lonely", View.two);
            Assert.AreEqual("Sociable", View.three);
            Assert.AreEqual("VerySociable", View.four);
            Assert.AreEqual("How do you feel?", View.title);

            pres.moodButtonPressed("Lonely");
            Assert.AreEqual("Update now!", View.one);
            Assert.AreEqual("Hidden", View.two);
            Assert.AreEqual("Hidden", View.three);
            Assert.AreEqual("Hidden", View.four);
            Assert.AreEqual("Do you want to update your Mood?", View.title);

            Assert.AreEqual(false, View.showAllMoodButtonsFlag);
            Assert.IsNotNull(View.ActivityList);
        }
Exemplo n.º 8
0
        public void TestChangeBetweenChallengeAndActivity()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            // In the current form changeBetweenChallengeAndActivity takes gui elements. This should not be the case.
            // It should instead take strings and communicate back via the interface IActivityMain by calling methods
            // and passing arguments as strings. Once this is done
        }
Exemplo n.º 9
0
        public void TestActivityGradeButtonPressed()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            pres.activityGradeButtonPressed(2, "THIS WAS AUTO-GENERATED FROM A TEST, REMOVE FROM THE DATABASE");

        }
Exemplo n.º 10
0
        public void TestTimer()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            // The following is a stub...
            /* XXX MUST BE REPLACED BY AN ACTIVITY USING THE TIMER!
            pres.startButtonPressed(XXX);
            int timeLeft = user.CurrentActivity.TimeLeft;
            for (int i = 0; i < timeLeft; i++)
            {
                pres.timerTick();
                Assert.AreEqual(String.Format("{0:00} min {1:00} sec", timeLeft / 60, timeLeft % 60), View.testTimeLeft);
            }
            pres.timerTick();
            Assert.AreEqual(true, View.testcreateActivityPopUp);
            */

        }
Exemplo n.º 11
0
        public void TestStartButtonPressed()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            // The following is a stub...

            // The activity test is covered by TestTimer
            // For challange:
            // Once adapted to the MVP pattern [labelDescription.Text = "Description"] and [l.Text = "Activities for challenge"] should be set
            // using a method (in IActivityMain) that takes 2 string params. These needs to be verified using the MockView...
        }
Exemplo n.º 12
0
        public void TestChallengePressed()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            pres.challengePressed("Flexibility & Strength");

            Assert.AreEqual("Complete both Strength of an ox and Limbo Master to finish this challenge!", View.testChallangeDescription);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public void TestGetRecommendedActivities()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<MoodType> CuresMoods = new List<MoodType>();
            CuresMoods.Add(MoodType.Sad);

            Assert.AreEqual(0, User.GetRecommendedActivities().Count);
        }
Exemplo n.º 15
0
        public void TestCompleteActivityWithNullParameter() {
            string UserName = "******";
            User User = new User(UserName);
            CurrentActivity Activity = null;

            Assert.AreEqual(0, User.CompleteActivity(Activity, ActivityGrade.Good, "I just broke the system, haha").Count);
        }
Exemplo n.º 16
0
        public void TestFailCurrentChallenge()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<Activity> requirements = new List<Activity>();
            requirements.Add(new Activity("John Doe", "Complete me", 3, 4, null));
            Challenge Challange = new Challenge("test", "do me", new Time(0, 0, 0), new Time(0, 0, 01), requirements);

            User.SetCurrentChallenge(Challange);

            Assert.AreEqual(Challange, User.CurrentChallenge.Challenge);

            User.FailCurrentChallenge();

            Assert.AreEqual(null, User.CurrentChallenge);
        }
Exemplo n.º 17
0
        public void TestCompleteCurrentChallengeWhenDeadlineExpired()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<Activity> requirements = new List<Activity>();
            requirements.Add(new Activity("John Doe", "Complete me", 3, 4, null));
            Challenge Challange = new Challenge("test", "do me", new Time(0, 0, 0), new Time(0, 0, 01), requirements);

            User.SetCurrentChallenge(Challange);

            User.CompleteCurrentChallenge();
        }
Exemplo n.º 18
0
        public void TestCompleteCurrentChallengeWhenPossible()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<Activity> requirements = new List<Activity>();
            requirements.Add(new Activity("John Doe", "Complete me", 3, 4, null));
            Challenge Challenge = new Challenge("test", "do me", new Time(0, 0, 0), new Time(23, 59, 59), requirements);

            Assert.AreEqual(false, User.CompletedChallenges.Contains(Challenge));

            User.SetCurrentChallenge(Challenge);
            User.CompleteCurrentChallenge();

            Assert.AreEqual(null, User.CurrentChallenge);
            Assert.AreEqual(true, User.CompletedChallenges.Contains(Challenge));
        }
Exemplo n.º 19
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());
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        public void TestActivityPressed()
        {
            MockView View = new MockView();
            User user = new User("testUser");
            Presenter pres = new Presenter(View, user);

            pres.activityPressed("Limbo");

            Assert.AreEqual("How low can you go?", View.testActivityDescription);
        }
Exemplo n.º 22
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);
        }