Beispiel #1
0
        public void EditUserValid()
        {
            tests = new UserManagementTests();

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

            this.tests.Storage.CreateUser(temp);

            temp = this.tests.Storage.GetUser("name");

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

            var model = new EditUserModel(expected);

            this.tests.Storage.EditUser(temp.Id, model);

            var compare = this.tests.Storage.GetUser("name");

            Assert.IsTrue(this.tests.TestUsers(compare, expected) && compare.OpenId == expected.OpenId);

            this.tests.Storage.DeleteUser(u => u.Username == "name");
        }
Beispiel #2
0
        public void EditUserValid()
        {
            User temp = new User {Username = "******", Email = "*****@*****.**", Password = "******"};

            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
            _Tests.Storage.CreateUser(temp);

            temp = _Tests.Storage.GetUser(u => u.Username == "name");

            User expected = new User
                                {
                                    Username = "******",
                                    Email = "*****@*****.**",
                                    Password = "******",
                                    Id = temp.Id,
                                    OpenId = "openid"
                                };

            var model = new EditUserModel(expected);
            _Tests.Storage.EditUser(temp.Id, model);

            var compare = _Tests.Storage.GetUser(u => u.Username == "name");
            Assert.IsTrue(_Tests.TestUsers(compare, expected) && compare.OpenId == expected.OpenId);

            _Tests.Storage.DeleteUser(u => u.Username == "name");
        }
Beispiel #3
0
 public void EditUser()
 {
     User temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };
     User expected = new User { Username = "******", Email = "*****@*****.**", Password = "******", Id = temp.Id , OpenId = "openid" };
     _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));
     _Tests.Storage.CreateUser(temp);
     var model = new EditUserModel(expected);
     _Tests.Storage.EditUser(temp.Id, model);
     //Assert.AreEqual(expected, _Tests.Storage.GetUser(u => u.Username == "ipvep"));
 }
Beispiel #4
0
        public void EditUserNonExisting()
        {
            User temp = new User { Username = "******", Email = "*****@*****.**", Password = "******" };

            _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza"));

            User expected = new User { Username = "******", Email = "*****@*****.**", Password = "******", Id = temp.Id, OpenId = "openid" };

            var model = new EditUserModel(expected);
            _Tests.Storage.EditUser(temp.Id, model);
        }
Beispiel #5
0
        public ActionResult Edit(Guid id,  EditUserModel user)
        {
            if (user.OpenId == null)
            {
                user.OpenId = string.Empty;
            }

            if (!ModelState.IsValid)
            {
                user.Password = null;
                //user.RolesList = _Storage.GetRoles().AsQueryable().Select(r => new SelectListItem { Text = IUDICO.UserManagement.Localization.getMessage(r.ToString()), Value = ((int)r).ToString(), Selected = (user.Role == r) });

                return View(user);
            }

            _Storage.EditUser(id, user);
 
            return RedirectToAction("Index");
        }
Beispiel #6
0
        public ActionResult Edit(Guid id, EditUserModel user)
        {
            if (user.OpenId == null)
            {
                user.OpenId = string.Empty;
            }

            if (!this.ModelState.IsValid)
            {
                user.Password = null;

                return this.View(user);
            }

            if (!this.storage.UserUniqueIdAvailable(user.UserId, user.Id))
            {
                this.ModelState.AddModelError("UserId", Localization.GetMessage("Unique ID Error"));

                return this.View(user);
            }

            if (!this.storage.UserOpenIdAvailable(user.OpenId, user.Id))
            {
                this.ModelState.AddModelError("OpenId", Localization.GetMessage("OpenIdError"));

                return this.View(user);
            }

            this.storage.EditUser(id, user);

            return this.RedirectToAction("Index");
        }
Beispiel #7
0
        public void EditUserNonExisting()
        {
            tests = new UserManagementTests();

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

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

            var model = new EditUserModel(expected);

            this.tests.Storage.EditUser(temp.Id, model);
        }