示例#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();
 }
示例#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();
 }
 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);
 }