public void CreateUsers()
        {
            UserStore <MockUser, MockRole, MockUserToken> userStore = TestInit.GetEmptyUserStore();

            String         emailAddress1 = "*****@*****.**";
            String         userName1     = "MisterTest1";
            IdentityResult result        = userStore.CreateAsync(new MockUser {
                Email = emailAddress1, UserName = userName1
            }, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Succeeded);

            String emailAddress2 = "*****@*****.**";
            String userName2     = "MisterTest2";

            result = userStore.CreateAsync(new MockUser {
                Email = emailAddress2, UserName = userName2
            }, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Succeeded);

            String emailAddress3 = "*****@*****.**";
            String userName3     = "MisterTest3";

            result = userStore.CreateAsync(new MockUser {
                Email = emailAddress3, UserName = userName3
            }, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Succeeded == true);

            Assert.Equal(3, userStore.Users.Count());
        }
        public void CreateUser()
        {
            UserStore <MockUser, MockRole, MockUserToken> userStore = TestInit.GetEmptyUserStore();
            IdentityResult result = userStore.CreateAsync(new MockUser {
                Email = "*****@*****.**", UserName = "******", PasswordHash = ""
            }, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Succeeded == true);
        }
        public void CreateRole()
        {
            var            roleStore = TestInit.GetEmptyRoleStore();
            IdentityResult result    = roleStore.CreateAsync(new MockRole {
                Name = "FirstOne"
            }, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Succeeded == true);
        }
        public void CreateAndFetchUser()
        {
            UserStore <MockUser, MockRole, MockUserToken> userStore = TestInit.GetEmptyUserStore();
            String emailAddress = "*****@*****.**";
            var    user         = new MockUser {
                Email = emailAddress, UserName = "******", PasswordHash = ""
            };
            IdentityResult result = userStore.CreateAsync(user, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Succeeded == true);

            var users = userStore.Users.ToList();

            Assert.Collection(users, (ux) => {
                Assert.Equal(emailAddress, ux.Email);
            });

            var usr = users.FirstOrDefault(u => u.Email == emailAddress);

            user = userStore.FindByEmailAsync(usr.NormalizedEmail, new System.Threading.CancellationToken()).Result;

            Assert.NotNull(user);
        }
        public void CreateAndFetchRole()
        {
            var    roleStore = TestInit.GetEmptyRoleStore();
            String name      = "FirstOne";
            var    role      = new MockRole {
                Name = name
            };
            IdentityResult result = roleStore.CreateAsync(role, new System.Threading.CancellationToken()).Result;

            Assert.True(result.Succeeded == true);

            var roles = roleStore.Roles.ToList();

            Assert.Collection(roles, (ux) => {
                Assert.Equal(name, ux.Name);
            });

            var rls = roles.FirstOrDefault(u => u.Name == name);

            role = roleStore.FindByNameAsync(role.NormalizedName, new System.Threading.CancellationToken()).Result;

            Assert.NotNull(role);
        }
        public void AddRoleToUser()
        {
            var stores = TestInit.GetEmptyStores();

            UserStore <MockUser, MockRole, MockUserToken> userStore = stores.Item2;
            String         userName     = "******";
            String         emailAddress = "*****@*****.**";
            IdentityResult result       = userStore.CreateAsync(new MockUser {
                Email = emailAddress, UserName = userName, NormalizedUserName = userName.ToUpperInvariant(), NormalizedEmail = emailAddress.ToUpperInvariant()
            }, new System.Threading.CancellationToken()).Result;

            //var user = userStore.Users.Single();

            //var roleStore = stores.Item1;
            //String name = "FirstOne";
            //result = roleStore.CreateAsync(new MockRole { Name = name, NormalizedName = name.ToUpperInvariant() }, new System.Threading.CancellationToken()).Result;

            //var role = roleStore.Roles.Single();

            //userStore.AddToRoleAsync(user, role.NormalizedName, new System.Threading.CancellationToken()).Wait();

            //Assert.True(userStore.IsInRoleAsync(user, role.NormalizedName, new System.Threading.CancellationToken()).Result);
        }