/// <summary>
 /// Converts the user entered data into a User object.
 /// </summary>
 /// <param name="encryption">Business class used to encrypt
 /// the password entered by the user.</param>
 /// <returns>User object made up of this data.</returns>
 public virtual User ToUser(IEncryption encryption)
 {
     var user = new User();
     user.Username = Username;
     user.MakeAdmin();
     user.SetPassword(encryption.Encrypt(Password));
     return user;
 }
Exemplo n.º 2
0
 public void MakeAdmin_NotAnAdmin_AddsAdminRoleToRoles()
 {
     var user = new User();
     user.MakeAdmin();
     Assert.That(user.Roles.Contains(Role.Admin), Is.True);
 }
Exemplo n.º 3
0
 public void MakeAdmin_AlreadyAdmin_DoesntDuplicateAdminRoleInRoles()
 {
     var user = new User { Roles = new List<string> { Role.Admin } };
     user.MakeAdmin();
     Assert.That(user.Roles.Where(x => x == Role.Admin).Count(), Is.EqualTo(1));
 }