예제 #1
0
        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));
        }
예제 #2
0
        public void CreateUserRejectsDuplicateUsername()
        {
            const string username = "******";

            var repository = new InMemoryUserRepository();

            repository.CreateUser(username);

            Assert.Throws <InvalidOperationException>(
                () => repository.CreateUser(username)
                );
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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));
        }