public void CreateUser_WithValidUsernamePassword_ReturnsUserId()
        {
            // Arrange
            const string username = "******";
            const string password = "******";
            const string email = "email";
            const int userId = 1;
            var service = new AccountService(_users.Object);
            var createdUser = new User{ Id = userId};
            _users.Setup(u => u.CreateUser(It.IsAny<User>())).Returns(createdUser);
            // Act

            var result = service.CreateUser(username, email, password);

            // Assert
            Assert.That(result, Is.EqualTo(userId));
        }
Пример #2
0
 public User CreateUser(User user)
 {
     if (user.Id == 0)
     {
         //moneyLogEntry.Date = DateTime.Now;
         _context.Users.InsertOnSubmit(user);
     }
     else if (_context.Users.GetOriginalEntityState(user) == null)
     {
         _context.Users.Attach(user);
         _context.Users.Context.Refresh(RefreshMode.KeepCurrentValues, user);
     }
     try
     {
         _context.Users.Context.SubmitChanges();
     }catch(SqlException exception)
     {
         //log error
     }
     return user;
 }
 partial void UpdateUser(User instance);
 partial void DeleteUser(User instance);
 partial void InsertUser(User instance);