Esempio n. 1
0
        public void TestGetExercises_OnlyBicepsAvailableForUser()
        {
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            criteria.ExerciseTypes.Add(Service.Model.ExerciseType.Biceps);
            var                   profile  = (ProfileDTO)profiles[0].Tag;
            SessionData           data     = SecurityManager.CreateNewSession(profile, ClientInformation);
            PartialRetrievingInfo pageInfo = new PartialRetrievingInfo();

            pageInfo.PageSize = 50;
            PagedResult <ExerciseDTO> result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                result = service.GetExercises(data.Token, criteria, pageInfo);
            });
            assertExercisesListPack(result, 7, new[] { "t02", "t04", "t05", "t12", "t14", "t15", "t25" }, null);

            profile = (ProfileDTO)profiles[1].Tag;
            data    = SecurityManager.CreateNewSession(profile, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                result = service.GetExercises(data.Token, criteria, pageInfo);
            });
            assertExercisesListPack(result, 7, new[] { "t02", "t04", "t05", "t21", "t25", "t12", "t15" }, null);
        }
Esempio n. 2
0
        public void WithoutIsDeleted()
        {
            var deletedExercise = CreateExercise(Session, null, "test", "tt");

            deletedExercise.IsDeleted = true;
            insertToDatabase(deletedExercise);
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            criteria.ExerciseTypes.Add(Service.V2.Model.ExerciseType.Klatka);

            var                   profile  = (ProfileDTO)profiles[0].Tag;
            SessionData           data     = CreateNewSession(profile, ClientInformation);
            PartialRetrievingInfo pageInfo = new PartialRetrievingInfo();

            pageInfo.PageSize = 50;

            PagedResult <ExerciseDTO> result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                result = service.GetExercises(data.Token, criteria, pageInfo);
            });

            var count = result.Items.Where(x => x.GlobalId == deletedExercise.GlobalId).Count();

            Assert.AreEqual(0, count);
        }
Esempio n. 3
0
        public void TestGetExercises_AllAvailableForUser()
        {
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            var                   profile  = (ProfileDTO)profiles[0].Tag;
            SessionData           data     = SecurityManager.CreateNewSession(profile, ClientInformation);
            PartialRetrievingInfo pageInfo = new PartialRetrievingInfo();

            pageInfo.PageSize = 50;
            PagedResult <ExerciseDTO> result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.GetExercises(data.Token, criteria, pageInfo);
            });
            assertExercisesListPack(result, 22, new[] { "t01", "t02", "t03", "t04", "t05", "t06", "t07", "t08",
                                                        "t11", "t12", "t13", "t14", "t15", "t16", "t17", "t18", "t19",
                                                        "t22", "t23", "t25", "t26" }, null);

            profile = (ProfileDTO)profiles[1].Tag;
            data    = SecurityManager.CreateNewSession(profile, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.GetExercises(data.Token, criteria, pageInfo);
            });
            assertExercisesListPack(result, 21, new[] { "t01", "t02", "t03", "t04", "t05", "t06", "t07", "t08",
                                                        "t21", "t22", "t23", "t24", "t25", "t26", "t27", "t28",
                                                        "t12", "t13", "t15", "t16", "t19" }, null);
        }
Esempio n. 4
0
        public void TestGetExercises_UserName()
        {
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            criteria.UserId = profiles[1].Id;

            var                   profile  = (ProfileDTO)profiles[0].Tag;
            SessionData           data     = SecurityManager.CreateNewSession(profile, ClientInformation);
            PartialRetrievingInfo pageInfo = new PartialRetrievingInfo();

            pageInfo.PageSize = 50;

            PagedResult <ExerciseDTO> result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.GetExercises(data.Token, criteria, pageInfo);
            });

            assertExercisesListPack(result, 5, new[] { "t22", "t23", "t25", "t26", "t28" }, null);

            profile = (ProfileDTO)profiles[1].Tag;
            data    = SecurityManager.CreateNewSession(profile, ClientInformation);
            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.GetExercises(data.Token, criteria, pageInfo);
            });

            assertExercisesListPack(result, 8, new[] { "t21", "t22", "t23", "t24", "t25", "t26", "t27", "t28" }, null);
        }
        public void TestPublishWorkoutPlan_CrossProfile()
        {
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            criteria.UserId = profiles[1].Id;

            var         profile = (ProfileDTO)profiles[1].Tag;
            SessionData data    = SecurityManager.CreateNewSession(profile, ClientInformation);
            var         plan    = (WorkoutPlanDTO)workoutPlans["test1-2"].Tag;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                Service.PublishWorkoutPlan(data.Token, plan);
            });
        }
Esempio n. 6
0
        public void TestGetExercises_SortOrder_Rating()
        {
            RatingUserValue rating = new RatingUserValue();

            rating.RatedObjectId = exercises["t05"].GlobalId;
            rating.ProfileId     = profiles[0].Id;
            rating.Rating        = 5;
            insertToDatabase(rating);

            rating = new RatingUserValue();
            rating.RatedObjectId = exercises["t02"].GlobalId;
            rating.ProfileId     = profiles[1].Id;
            rating.Rating        = 5;
            insertToDatabase(rating);

            rating = new RatingUserValue();
            rating.RatedObjectId = exercises["t04"].GlobalId;
            rating.ProfileId     = profiles[1].Id;
            rating.Rating        = 3;
            insertToDatabase(rating);

            rating = new RatingUserValue();
            rating.RatedObjectId = exercises["t01"].GlobalId;
            rating.ProfileId     = profiles[0].Id;
            rating.Rating        = 1;
            insertToDatabase(rating);

            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            criteria.SortOrder = WorkoutPlanSearchOrder.HighestRating;

            var                   profile  = (ProfileDTO)profiles[0].Tag;
            SessionData           data     = SecurityManager.CreateNewSession(profile, ClientInformation);
            PartialRetrievingInfo pageInfo = new PartialRetrievingInfo();

            pageInfo.PageSize = 50;
            PagedResult <ExerciseDTO> result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.GetExercises(data.Token, criteria, pageInfo);
            });
            Assert.AreEqual("t05", result.Items[0].Shortcut);
            Assert.AreEqual("t02", result.Items[1].Shortcut);
            Assert.AreEqual("t04", result.Items[2].Shortcut);
            Assert.AreEqual("t01", result.Items[3].Shortcut);
        }
        public void TestPublishWorkoutPlan_NotPublishedExercises()
        {
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            criteria.UserId = profiles[1].Id;

            var         profile = (ProfileDTO)profiles[0].Tag;
            SessionData data    = SecurityManager.CreateNewSession(profile, ClientInformation);
            var         plan    = (WorkoutPlanDTO)workoutPlans["test1-2"].Tag;

            Assert.AreEqual(BodyArchitect.Service.Model.PublishStatus.Private, plan.Status);

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                Service.PublishWorkoutPlan(data.Token, plan);
            });
        }
Esempio n. 8
0
        public void Fill(ProfileInformationDTO user, bool isActive)
        {
            if (user != null)
            {
                if (isActive && (!filled || currentUser == null || currentUser.User.Id != user.User.Id))
                {
                    filled = true;
                    ExerciseSearchCriteria criteria = ExerciseSearchCriteria.CreateAllCriteria();
                    criteria.UserId = user.User.Id;
                    usrExercisesView1.Fill(criteria);
                }
            }
            else
            {
                usrExercisesView1.ClearContent();
            }

            currentUser = user;
        }
Esempio n. 9
0
        public void All()
        {
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            var                   profile  = (ProfileDTO)profiles[0].Tag;
            SessionData           data     = CreateNewSession(profile, ClientInformation);
            PartialRetrievingInfo pageInfo = new PartialRetrievingInfo();

            pageInfo.PageSize = 50;

            PagedResult <ExerciseDTO> result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.GetExercises(data.Token, criteria, pageInfo);
            });

            assertExercisesListPack(result, new[] { "t01", "t02", "t03", "t11", "t12", "t21", "t22" });
        }
Esempio n. 10
0
        public void MineAndFavorites_ForCurrentUser()
        {
            var criteria = ExerciseSearchCriteria.CreateAllCriteria();

            criteria.SearchGroups.Add(ExerciseSearchCriteriaGroup.Mine);
            criteria.SearchGroups.Add(ExerciseSearchCriteriaGroup.Favorites);
            var                   profile  = (ProfileDTO)profiles[0].Tag;
            SessionData           data     = CreateNewSession(profile, ClientInformation);
            PartialRetrievingInfo pageInfo = new PartialRetrievingInfo();

            pageInfo.PageSize = 50;

            PagedResult <ExerciseDTO> result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                result = service.GetExercises(data.Token, criteria, pageInfo);
            });

            assertExercisesListPack(result, new[] { "t11", "t12", "t22" });
        }
Esempio n. 11
0
        protected override void BeforeSearch(object param = null)
        {
            criteria = ExerciseSearchCriteria.CreateAllCriteria();

            foreach (var value in exerciseTypes)
            {
                if (value.IsChecked)
                {
                    criteria.ExerciseTypes.Add(value.Value);
                }
            }
            foreach (var value in SearchGroups)
            {
                if (value.IsChecked)
                {
                    criteria.SearchGroups.Add(value.Value);
                }
            }

            criteria.Name = ExerciseName;

            criteria.SortOrder     = SelectedOrder;
            criteria.SortAscending = SortAscending;
        }