Esempio n. 1
0
 public Role Add(Role item)
 {
     var newRole = (Role)item.Clone();
     newRole.Id = !_roles.Any() ? 1 : _roles.Max(rate => rate.Id) + 1;
     _roles.Add(newRole);
     return (Role)newRole.Clone();
 }
Esempio n. 2
0
 public Role Update(Role item)
 {
     var existRole = _roles.SingleOrDefault(role => role.Id == item.Id);
     if (existRole == null)
     {
         throw new NullReferenceException();
     }
     existRole.RoleType = item.RoleType;
     return (Role)existRole.Clone();
 }
Esempio n. 3
0
 public void AddTest()
 {
     var type = Guid.NewGuid().ToString();
     var NewRole = new Role
     {
         RoleType = type
     };
     var AddedRole = service.Add(NewRole);
     Assert.IsNotNull(AddedRole);
     Assert.IsTrue(AddedRole.Id > 0);
     Assert.AreEqual(AddedRole.RoleType, type);
 }