Inheritance: MedalRequirementsChecker
        public void CheckIfFullfiledRequirementTest_ShouldCheckListWhichAlredyContainThisMedalAndReturnEmptyMedalList()
        {
            //Arrange
            SpontaneousUserModel userModelWithMedal = new SpontaneousUserModel()
            {
                UserMedalsList = new List<UserMedal>()
            };
            userModelWithMedal.UserMedalsList.Add(new WelcomeUserMedal());
            UserActivity userActivity = new PageViewActivity("TestPage");

            //Act
            MedalRequirementsChecker medalChecker = new PlatefulMedalRequirementChecker();
            List<UserMedal> userModelWithMedalResult = medalChecker.ObtainMedalBecauseOfActivity(userModelWithMedal, userActivity);

            //Assert
            Assert.AreEqual(userModelWithMedalResult.Count, 0);
        }
        public void CheckIfFullfiledRequirementTest_ShouldCheckListWithoutThisMedalAndRequirementForThisMedalNotAchieved_MustReturnNotEmptyMedalList()
        {
            //Arrange
            SpontaneousUserModel userModelWithOutMedal = new SpontaneousUserModel()
            {
                UserActivityList = new List<UserActivity>(),
                UserMedalsList = new List<UserMedal>()
            };
            //Requirement = 3
            //for (int i = 0; i < 2; i++)
            //{
            //    userModelWithOutMedal.UserActivityList.Add(new PageViewActivity("TestPage"));
            //}
            UserActivity userActivity = new PageViewActivity("TestPage");

            //Act
            MedalRequirementsChecker medalChecker = new PlatefulMedalRequirementChecker();
            List<UserMedal> userModelWithMedalResult = medalChecker.ObtainMedalBecauseOfActivity(userModelWithOutMedal, userActivity);

            //Assert
            Assert.AreEqual(userModelWithMedalResult.Count, 0);
        }
        public void CheckIfFullfiledRequirementTest_ShouldCheckListWithOtherMedalAndReturnNotEmptyMedalList()
        {
            //Arrange
            SpontaneousUserModel userModelWithOtherMedal = new SpontaneousUserModel()
            {
                UserActivityList = new List<UserActivity>(),
                UserMedalsList = new List<UserMedal>()
            };
            for (int i = 0; i < 3; i++)
            {
                userModelWithOtherMedal.UserActivityList.Add(new PageViewActivity("TestPage"));
            }
            userModelWithOtherMedal.UserMedalsList.Add(new AddRestaurantMedal());
            UserActivity userActivity = new PageViewActivity("TestPage");

            //Act
            MedalRequirementsChecker medalChecker = new PlatefulMedalRequirementChecker();
            List<UserMedal> userModelWithOtherMedalResult = medalChecker.ObtainMedalBecauseOfActivity(userModelWithOtherMedal, userActivity);

            //Assert
            Assert.AreNotEqual(userModelWithOtherMedalResult.Count, 0);
        }
Esempio n. 4
0
 private MedalRequirementsChecker factoryMedalChecker()
 {
     MedalRequirementsChecker returnvalue = null;
     switch (AppName)
     {
         case ApplicationName.Spontaneous:
             returnvalue = new SpontaneousMedalRequirementChecker();
             break;
         case ApplicationName.Plateful:
             returnvalue = new PlatefulMedalRequirementChecker();
             break;
     }
     return returnvalue;
 }
Esempio n. 5
0
        internal MedalProgress GetClosesMedal()
        {
            var userProfile = GetUserProfile();
            var userData = userProfile.GetUserData();

            if (userData == null)
            {
                log.WarnFormat("[GetClosesMedal] User={0} tried to get GetClosesMedal, but userData doesn't exists.", userProfile.UserName);
                return null;
            }

            MedalProgress returnValue;

            MedalRequirementsChecker medalChecker;
            switch (AppName)
            {
                case ApplicationName.Spontaneous:
                    log.InfoFormat("[GetClosesMedal] Spontaneous : user={0}.", userProfile.UserName);
                    medalChecker = new SpontaneousMedalRequirementChecker();
                    break;
                case ApplicationName.Plateful:
                    log.InfoFormat("[GetClosesMedal] Platefull : user={0}.", userProfile.UserName);
                    medalChecker = new PlatefulMedalRequirementChecker();
                    break;
                case ApplicationName.BackOffice:
                    log.InfoFormat("[GetClosesMedal] BackOffice : user={0}.", userProfile.UserName);
                    return null;
                default:
                    log.InfoFormat("[GetClosesMedal] default : user={0}.", userProfile.UserName);
                    return null;
            }

            returnValue = medalChecker.getClosesMedal(userData);

            //var medals = userData.UserMedalsList;
            log.InfoFormat("[GetClosesMedal] user={0}, MedalProgress = MedalProgress.ToString Function Not implemented.", userProfile.UserName);
            return returnValue;
        }
        public void getMedalProgressesTest_AlreadyHaveWelcomUserMedal_MustReturnNotEmptyMedalProgressesList_Count1()
        {
            //Arrang
            MedalRequirementsChecker requirementChecker = new PlatefulMedalRequirementChecker();
            SpontaneousUserModel userModel = new SpontaneousUserModel()
            {
                UserActivityList = new List<UserActivity>(),
                UserMedalsList = new List<UserMedal>()
            };

            userModel.UserActivityList.Add(new PageViewActivity("TestPage"));
            userModel.UserMedalsList.Add(new WelcomeUserMedal());

            //Act
            List<MedalProgress> medalProgresses = requirementChecker.getMedalProgresses(userModel);

            //Assert

            Assert.AreEqual(medalProgresses.Count, 5);
        }
        public void getMedalProgressesTestWithOtherActivity_MustReturnNotEmptyMedalProgressesList()
        {
            //Arrang
            MedalRequirementsChecker requirementChecker = new PlatefulMedalRequirementChecker();
            SpontaneousUserModel userModel = new SpontaneousUserModel()
            {
                UserActivityList = new List<UserActivity>(),
                UserMedalsList = new List<UserMedal>()
            };

            userModel.UserActivityList.Add(new PageViewActivity("TestPage"));

            //Act
            List<MedalProgress> medalProgresses = requirementChecker.getMedalProgresses(userModel);

            //Assert

            Assert.IsNotNull(medalProgresses);
            Assert.IsTrue(medalProgresses.Count > 0);
        }
        public void getClosesMedalTest__MustReturnClosestsMedalProgres_of_WelcomeUserMedal()
        {
            //Arrang
            MedalRequirementsChecker requirementChecker = new PlatefulMedalRequirementChecker();
            SpontaneousUserModel userModel = new SpontaneousUserModel()
            {
                UserActivityList = new List<UserActivity>(),
                UserMedalsList = new List<UserMedal>()
            };

            //userModel.UserActivityList.Add(new PageViewActivity("TestPage"));

            //Act
            MedalProgress progress = requirementChecker.getClosesMedal(userModel);

            //Assert
            string massage = "";
            Assert.AreEqual(progress.MedalType, "WelcomeUserMedal", true, massage);
            Assert.AreEqual(progress.pointsRequired, 1);
            Assert.AreEqual(progress.ProgressPercentage, 0);
        }
        public void getClosesMedalTest_AlreadyHaveWelcomMedal_MustReturnClosestsMedalProgres_of_RestaurantAdviserMedalProgress()
        {
            //Arrang
            MedalRequirementsChecker requirementChecker = new PlatefulMedalRequirementChecker();
            SpontaneousUserModel userModel = new SpontaneousUserModel()
            {
                UserActivityList = new List<UserActivity>(),
                UserMedalsList = new List<UserMedal>()
            };

            userModel.UserActivityList.Add(new InviteFriendActivity());
            userModel.UserMedalsList.Add(new WelcomeUserMedal());

            //Act
            MedalProgress progress = requirementChecker.getClosesMedal(userModel);
            int progressPercentage = progress.GetProgressPercentage();

            //Assert
            string massage = "";
            Assert.AreEqual(progress.MedalType, "RestaurantAdviserMedal", true, massage);
            Assert.AreEqual(progress.pointsRequired, 4);
            Assert.AreEqual(progressPercentage, 50);
        }