Ejemplo n.º 1
0
        public async Task SetUserName_Test()
        {
            var store = new ElasticUserStore <ElasticUser, ElasticRole>(_nestClient, new ElasticOptions {
                UsersIndex = _userIndex
            });
            var user = new ElasticUser
            {
                UserName     = "******",
                PasswordHash = "phash",
                Logins       = new List <ElasticUserLogin> {
                    new ElasticUserLogin(new UserLoginInfo("prov1", "key1", "test1")),
                    new ElasticUserLogin(new UserLoginInfo("prov2", "key2", "test2"))
                },
                Email = new ElasticConfirmation("*****@*****.**")
            };
            var createResult = await store.CreateAsync(user, NoCancellationToken);

            await store.SetUserNameAsync(user, "test11", NoCancellationToken);

            await store.UpdateAsync(user, NoCancellationToken);

            var elasticUser = await store.FindByIdAsync(user.Id, NoCancellationToken);

            Assert.Equal(createResult, IdentityResult.Success);
            Assert.Equal(user.UserName, elasticUser.UserName);
        }