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