public void CreateUserGeneratesUniqueIds() { const string username1 = "TestUser1"; const string username2 = "TestUser2"; var repository = new InMemoryUserRepository(); var createdUser1 = repository.CreateUser(username1); var createdUser2 = repository.CreateUser(username2); Assert.That(createdUser1.Id, Is.Not.EqualTo(createdUser2.Id)); }
public void CreateUserRejectsDuplicateUsername() { const string username = "******"; var repository = new InMemoryUserRepository(); repository.CreateUser(username); Assert.Throws <InvalidOperationException>( () => repository.CreateUser(username) ); }
public void GetAllUsersReturnsAllCreatedUsers() { const string username1 = "TestUser1"; const string username2 = "TestUser2"; var repository = new InMemoryUserRepository(); var createdUser1 = repository.CreateUser(username1); var createdUser2 = repository.CreateUser(username2); var allUsers = repository.GetAllUsers().ToList(); Assert.That(allUsers.Count, Is.EqualTo(2)); Assert.That(allUsers, Contains.Item(createdUser1)); Assert.That(allUsers, Contains.Item(createdUser2)); }
public void GetUserByIdCanLocateUser() { const string username = "******"; var repository = new InMemoryUserRepository(); var createdUser = repository.CreateUser(username); var locatedUser = repository.GetUserById(createdUser.Id); Assert.That(createdUser, Is.EqualTo(locatedUser)); }
public void CreateUserCanAddUser() { const string username = "******"; var repository = new InMemoryUserRepository(); var createdUser = repository.CreateUser(username); Assert.That(createdUser, Is.Not.Null); Assert.That(createdUser.Id, Is.GreaterThan(0)); Assert.That(createdUser.Username, Is.EqualTo(username)); }