Ejemplo n.º 1
0
 public void GroupCreateGroup()
 {
     var group = new Group { Name = "group1" };
     var result = this.groupController.Create(group) as RedirectToRouteResult;
     
     Assert.IsNotNull(result);
     Assert.AreEqual("Index", result.RouteValues["action"]);
 }
Ejemplo n.º 2
0
        public void GetGroup()
        {
            var group = new Group { Deleted = false, Id = 323, Name = "pmp41" };
            
            _Tests.Storage.CreateGroup(group);

            Assert.AreEqual(group.Name, _Tests.Storage.GetGroup(group.Id).Name);
        }
Ejemplo n.º 3
0
        public void DeleteGroupSuccess()
        {
            var group = new Group { Deleted = false, Id = 333123456, Name = "pma31" };
            
            _Tests.Storage.CreateGroup(group);
            _Tests.Storage.DeleteGroup(group.Id);

            Assert.IsTrue(_Tests.Storage.GetGroup(group.Id) == null);
        }
Ejemplo n.º 4
0
        public void DeleteGroupExisting()
        {
            var group = new Group { Id = 123, Name = "pmi31" };

            this.tests.Storage.CreateGroup(group);
            this.tests.Storage.DeleteGroup(group.Id);

            Assert.IsTrue(this.tests.Storage.GetGroup(group.Id) == null);
        }
Ejemplo n.º 5
0
        public void CreateGroup()
        {
            var group = new Group { Deleted = false, Id = 12345678, Name = "pmi31" };
            
            _Tests.Storage.CreateGroup(group);

            Assert.AreEqual(group.Name, _Tests.Storage.GetGroup(group.Id).Name);
            
            _Tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 6
0
        public void GetGroupExisting()
        {
            var group = new Group { Id = 12, Name = "pmi31" };

            this.tests.Storage.CreateGroup(group);

            Assert.AreEqual(group, this.tests.Storage.GetGroup(group.Id));

            this.tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 7
0
        public void CreateGroupInvalid()
        {
            var group = new Group { Id = 4567, Name = "pma51" };

            _Tests.Storage.CreateGroup(group);

            Assert.IsTrue(group.Name == _Tests.Storage.GetGroup(group.Id).Name && group.Id == _Tests.Storage.GetGroup(group.Id).Id);
            
            _Tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 8
0
        public void RemoveNonExistingUserFromNonExistingGroup()
        {
            var group = new Group { Id = 345678, Name = "pmi31" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);
            this.tests.Storage.RemoveUserFromGroup(group, temp);

            Assert.AreEqual(null, this.tests.Storage.GetUser(u => u.Username == temp.Username));
            Assert.AreEqual(0, this.tests.Storage.GetGroupsByUser(temp).Count());
        }
Ejemplo n.º 9
0
        public void AddNonExistingUserToNonExistingGroup()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 12366, Name = "pmp51" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);

            Assert.IsFalse(this.tests.Storage.GetUsersInGroup(group).Contains(temp));
            Assert.AreEqual(0, this.tests.Storage.GetGroupsByUser(temp).Count());
        }
Ejemplo n.º 10
0
        public void EditGroupExistingValid()
        {
            var group = new Group { Id = 1254, Name = "pmp41" };

            _Tests.Storage.CreateGroup(group);
            group = new Group { Id = 1254, Name = "pmp51" };
            _Tests.Storage.EditGroup(group.Id,group);
            Assert.IsTrue(group.Name == _Tests.Storage.GetGroup(group.Id).Name && group.Id == _Tests.Storage.GetGroup(group.Id).Id);

            _Tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 11
0
        public void RemoveExistingUserFromNonExistingGroup()
        {
            var group = new Group { Id = 12677, Name = "pmi31" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.CreateUser(temp);
            temp = this.tests.Storage.GetUser(u => u.Username == temp.Username);

            this.tests.Storage.RemoveUserFromGroup(group, temp);
            Assert.IsFalse(this.tests.Storage.GetGroupsByUser(temp).Contains(group));

            this.tests.Storage.DeleteUser(u => u.Username == "name");
        }
Ejemplo n.º 12
0
        public void AddNonExistingUserToNonExistingGroup()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 12366, Name = "pmp51" };

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            _Tests.Storage.AddUserToGroup(group, temp);

            Assert.AreEqual(null, _Tests.Storage.GetUser(u => u.Username == temp.Username));
            Assert.AreEqual(0,_Tests.Storage.GetGroupsByUser(temp).Count());
        }
Ejemplo n.º 13
0
        public void AddExistingUserToNonExistingGroup()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 12366, Name = "pmp51" };
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.CreateUser(temp);
            temp = this.tests.Storage.GetUser(u => u.Username == temp.Username);

            this.tests.Storage.AddUserToGroup(group, temp);
            Assert.IsFalse(this.tests.Storage.GetGroupsByUser(temp).Contains(group));

            this.tests.Storage.DeleteUser(u => u.Username == "name");
        }
Ejemplo n.º 14
0
        public void CreateGroupInvalid()
        {
            tests = UserManagementTests.Update();

            var group = new Group { Id = 4567, Name = "pma51" };

            this.tests.Storage.CreateGroup(group);

            Assert.IsTrue(
                group.Name == this.tests.Storage.GetGroup(group.Id).Name
                && group.Id == this.tests.Storage.GetGroup(group.Id).Id);

            this.tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 15
0
        public void AddNonExistingUserToExistingGroup()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 1266678, Name = "pmi31" };
            this.tests.Storage.CreateGroup(group);
            group = this.tests.Storage.GetGroup(group.Id);
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);
            Assert.IsTrue(this.tests.Storage.GetGroupsByUser(temp).Contains(group));
            Assert.IsFalse(this.tests.Storage.GetUsersInGroup(group).Contains(temp));// this.tests.Storage.GetUser(temp.Username));

            this.tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 16
0
        public void GroupCreateGroupFail()
        {
            this.groupController.RouteData.Values["action"] = "Create";

            var group = new Group();
            
            this.groupController.ModelState.AddModelError("key", "error");
            
            var result = this.groupController.Create(group) as ViewResult;

            Assert.IsNotNull(result);

            var p = Path.GetFileNameWithoutExtension(result.ViewName);
            Assert.AreEqual("Create", Path.GetFileNameWithoutExtension(result.ViewName));
        }
Ejemplo n.º 17
0
        public void AddExistingUserToNonExistingGroup()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 12366, Name = "pmp51" };

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };
            _Tests.Storage.CreateUser(temp);
            temp = _Tests.Storage.GetUser(u => u.Username == temp.Username);

            _Tests.Storage.AddUserToGroup(group, temp);
            Assert.IsFalse(_Tests.Storage.GetGroupsByUser(temp).Contains(group));

            _Tests.Storage.DeleteUser(u => u.Username == "name");
        }
Ejemplo n.º 18
0
        public void AddNonExistingUserToExistingGroup()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 1266678, Name = "pmi31" };
            _Tests.Storage.CreateGroup(group);
            group = _Tests.Storage.GetGroup(group.Id);
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            _Tests.Storage.AddUserToGroup(group, temp);
            Assert.IsTrue(_Tests.Storage.GetGroupsByUser(temp).Contains(group));
            Assert.AreEqual(null, _Tests.Storage.GetUser(u => u.Username == temp.Username));

            _Tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 19
0
        public void GetGroupsAvailableToExistingUser()
        {
            tests = UserManagementTests.Update();
            var group = new Group { Id = 12345678, Name = "pmi31" };
            this.tests.Storage.CreateGroup(group);
            group = this.tests.Storage.GetGroup(group.Id);

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };
            this.tests.Storage.CreateUser(temp);
            temp = this.tests.Storage.GetUser(temp.Username);

            Assert.IsTrue(this.tests.Storage.GetGroupsAvailableToUser(temp).Contains(group));

            this.tests.Storage.DeleteUser(u => u.Username == "name");

            this.tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 20
0
        public void GetGroupsAvailableToExistingUser()
        {
            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            var group = new Group { Id = 12345678, Name = "pmi31" };
            _Tests.Storage.CreateGroup(group);
            group = _Tests.Storage.GetGroup(group.Id);
            
            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };
            _Tests.Storage.CreateUser(temp);
            temp = _Tests.Storage.GetUser(u => u.Username == temp.Username);

            Assert.IsTrue(_Tests.Storage.GetGroupsAvailableToUser(temp).Contains(group));

            _Tests.Storage.DeleteGroup(group.Id);
            _Tests.Storage.DeleteUser(u => u.Username == "name");
        }
Ejemplo n.º 21
0
        public void RemoveNonExistingUserFromExistingGroup()
        {
            var group = new Group { Id = 12345678, Name = "pmi31" };

            this.tests.Storage.CreateGroup(group);

            group = this.tests.Storage.GetGroup(group.Id);

            var temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            this.tests.Storage.AddUserToGroup(group, temp);
            this.tests.Storage.RemoveUserFromGroup(group, temp);

            Assert.IsFalse(this.tests.Storage.GetGroupsByUser(temp).Contains(group));
            Assert.AreEqual(null, this.tests.Storage.GetUser(u => u.Username == temp.Username));

            this.tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 22
0
        public void InvalidateGroup()
        {
            // original caching
            //this.tests.Storage.GetGroups();
            tests = UserManagementTests.Update();

            var group = new Group { Id = 1254, Name = "pmp41" };

            this.tests.Storage.CreateGroup(group);

            group = new Group { Id = 1254, Name = "pmp51" };

            this.tests.Storage.EditGroup(group.Id, group);

            Assert.IsTrue(
                group.Name == this.tests.Storage.GetGroup(group.Id).Name
                && group.Id == this.tests.Storage.GetGroup(group.Id).Id);

            this.tests.Storage.DeleteGroup(group.Id);
        }
Ejemplo n.º 23
0
 public void GetDisciplinesByGroupId()
 {
     List<Discipline> disciplines = CreateDefaultData();
     disciplines.ForEach(item => _Storage.AddDiscipline(item));
     Group group = new Group {Id = 1, Name = "Group1"};
     var curriculums = disciplines.Select(item => new Curriculum {Discipline = item, UserGroupRef = group.Id})
         .ToList();
     curriculums.ForEach(i => _Storage.AddCurriculum(i));
     Assert.AreEqual(disciplines, _Storage.GetDisciplinesByGroupId(group.Id).ToList());
 }
Ejemplo n.º 24
0
 public IEnumerable<Group> AvailebleGroups(int topicId)
 {
     //User teacherUser = _LmsService.FindService<IUserService>().GetCurrentUser();
     //return _LmsService.FindService<ICurriculumService>().GetTopicsOwnedByUser(teacherUser);
     Group i41 = new Group();
     i41.Id = 1;
     i41.Name = "PMI 41";
     Group i42 = new Group();
     i42.Id = 2;
     i42.Name = "PMI 42";
     Group i43 = new Group();
     i43.Id = 3;
     i43.Name = "PMI 43";
     List<Group> res = new List<Group>();
     res.Add(i41);
     res.Add(i42);
     res.Add(i43);
     return res;
 }
Ejemplo n.º 25
0
        public GroupTopicStat GetGroupTopicStatistic(Topic topic, Group group)
        {
            var results = GetResults(topic);

            var groupResults = results.Where(r => r.User.GroupUsers.Select(g => g.GroupRef)
                                      .Contains(group.Id))
                                      .Select(r => new UserRating(r.User, r.Score.ToPercents().Value))
                                      .ToList();
            
            var usersParticipated = groupResults.Select(g => g.User);
            var n = usersParticipated.Count();

            if (n == 0)
            {
                return new GroupTopicStat(0, 0);
            }

            var usersIds = usersParticipated.Select(u => u.Id);

            var groupRatings = group.GroupUsers
                                    .Select(gu => new UserRating(gu.User, 1.0 * gu.User.TestsSum / gu.User.TestsTotal))
                                    .Where(gu => usersIds.Contains(gu.User.Id))
                                    .ToList();

            groupResults.Sort();
            groupRatings.Sort();

            var ratResults = groupResults.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User, a => a.Index);
            var ratRatings = groupRatings.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User, a => a.Index);

            var ratingDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(ratResults[u] - ratRatings[u]));
            var ratingMax = 2*((n + 1)/2)*(n/2);
            var ratingNormalized = ratingDifference/ratingMax;

            var diffResults = groupResults.ToDictionary(a => a.User, a => a.Score);
            var diffRatings = groupRatings.ToDictionary(a => a.User, a => a.Score);

            var scoreDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(diffResults[u] - diffRatings[u]));
            var scoreMax = n*100;
            var scoreNormalized = scoreDifference / scoreMax;

            return new GroupTopicStat(ratingNormalized, scoreNormalized);
        }
Ejemplo n.º 26
0
        public void EditGroupNonExisting()
        {
            var group = new Group { Id = 1253, Name = "pmp51" };

            this.tests.Storage.EditGroup(group.Id, group);
        }
Ejemplo n.º 27
0
        public GroupTopicStat GetGroupTopicStatistic(Topic topic, Group group)
        {
            //Всі результати по топіку
            var results = this.GetResults(topic);

            //Результати учнів тільки даної групи
            var groupResults = results.Where(r => r.User.GroupUsers.Select(g => g.GroupRef)
                                      .Contains(group.Id))
                                      .Where(s => s.Score.ToPercents()!=null)
                                      .Select(r => new UserRating(r.User, r.Score.ToPercents().Value))
                                      .ToList();
            
            var usersParticipated = groupResults.Select(g => g.User).ToList();
            var n = usersParticipated.Count();

            if (n == 0)
            {
                return new GroupTopicStat(0, 0);
            }

            var usersIds = usersParticipated.Select(u => u.Id);

            var groupRatings = group.GroupUsers
                                    .Select(gu => new UserRating(gu.User, (gu.User.TestsTotal > 0 ? 1.0 * gu.User.TestsSum / gu.User.TestsTotal : 0)))
                                    .Where(gu => usersIds.Contains(gu.User.Id))
                                    .ToList();

            groupResults.Sort();
            groupRatings.Sort();

            var ratResults = groupResults.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User.Id, a => a.Index);
            var ratRatings = groupRatings.Select((r, i) => new { User = r.User, Index = i }).ToDictionary(a => a.User.Id, a => a.Index);

            var ratingDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(ratResults[u.Id] - ratRatings[u.Id]));
            
            var ratingMax = (n * n + n) / 2;
            var ratingNormalized = 1 - (ratingDifference / ratingMax);

            var diffResults = groupResults.ToDictionary(a => a.User.Id, a => a.Score);
            var diffRatings = groupRatings.ToDictionary(a => a.User.Id, a => a.Score);

            var scoreDifference = 1.0 * usersParticipated.Sum(u => Math.Abs(diffResults[u.Id] - diffRatings[u.Id]));
            var scoreMax = n * 100;
            var scoreNormalized = 1 - (scoreDifference / scoreMax);

            return new GroupTopicStat(ratingNormalized, scoreNormalized);
        }
Ejemplo n.º 28
0
 partial void UpdateGroup(Group instance);
Ejemplo n.º 29
0
 partial void InsertGroup(Group instance);
Ejemplo n.º 30
0
 partial void DeleteGroup(Group instance);