예제 #1
0
 public User Add(User item)
 {
     var newUser = (User)item.Clone();
     newUser.Id = !_users.Any() ? 1 : _users.Max(user => user.Id) + 1;
     _users.Add(newUser);
     return (User)newUser.Clone();
 }
예제 #2
0
 public User Update(User item)
 {
     var existUser = _users.SingleOrDefault(user => user.Id == item.Id);
     if (existUser == null)
     {
         throw new NullReferenceException();
     }
     existUser.Login = item.Login;
     return (User)existUser.Clone();
 }
예제 #3
0
 public void AddTest()
 {
     var name = Guid.NewGuid().ToString();
     var NewUser = new User
     {
         Login = name
     };
     var AddedUser = service.Add(NewUser);
     Assert.IsNotNull(AddedUser);
     Assert.IsTrue(AddedUser.Id > 0);
     Assert.AreEqual(AddedUser.Login, name);
 }