Ejemplo n.º 1
0
        public async Task Details_InvalidUser_ReturnNull()
        {
            string USER_ID = Guid.NewGuid().ToString();

            var service = new AdminUserService(dbContext, userManager, roleManager, signInManager, new Mock <IServerNewsService>().Object);

            await service.DetailsAsync(USER_ID);

            UserDetailsViewModel userDetails = await service.DetailsAsync(USER_ID);

            Assert.IsNull(userDetails);
        }
Ejemplo n.º 2
0
        public async Task Details_ValidUserTwo2FA_Success()
        {
            string USER_ID = Guid.NewGuid().ToString();

            await dbContext.Users.AddAsync(new User("TestName", "TestUserName", "*****@*****.**", DateTime.Now) { Id = USER_ID, TwoFactorEnabled = true });

            await dbContext.SaveChangesAsync();

            var service = new AdminUserService(dbContext, userManager, roleManager, signInManager, new Mock <IServerNewsService>().Object);

            UserDetailsViewModel userDetails = await service.DetailsAsync(USER_ID);

            User foundUser = await dbContext.Users.FindAsync(USER_ID);

            Assert.IsNotNull(userDetails);

            Assert.AreEqual(foundUser.BirthDate, userDetails.BirthDate);
            Assert.AreEqual(foundUser.Email, userDetails.Email);
            Assert.AreEqual(foundUser.FullName, userDetails.FullName);
            Assert.AreEqual(foundUser.PhoneNumber, userDetails.PhoneNumber);
            Assert.AreEqual(foundUser.Qualification, userDetails.Qualification);
            Assert.AreEqual(foundUser.RegisteredDate, userDetails.RegisteredDate);
            Assert.AreEqual(foundUser.UserName, userDetails.Username);

            Assert.IsFalse(userDetails.IsPersonnel);
            Assert.IsFalse(userDetails.IsAdmin);
            Assert.IsFalse(userDetails.IsDoctor);
            Assert.IsTrue(userDetails.Is2FAEnabled);
            Assert.IsFalse(userDetails.IsEmailVerified);
        }
Ejemplo n.º 3
0
        public async Task Details_ValidPersonnelUser_Success()
        {
            string USER_ID = Guid.NewGuid().ToString();

            await dbContext.Users.AddAsync(new User("TestName", "TestUserName", "*****@*****.**", DateTime.Now) { Id = USER_ID });

            await dbContext.UserRoles.AddAsync(new IdentityUserRole <string>() { UserId = USER_ID, RoleId = dbContext.Roles.First(r => r.NormalizedName == Roles.PERSONNEL.ToUpperInvariant()).Id });

            await dbContext.SaveChangesAsync();

            var service = new AdminUserService(dbContext, userManager, roleManager, signInManager, new Mock <IServerNewsService>().Object);

            UserDetailsViewModel userDetails = await service.DetailsAsync(USER_ID);

            User foundUser = await dbContext.Users.FindAsync(USER_ID);

            Assert.IsNotNull(userDetails);

            Assert.AreEqual(foundUser.BirthDate, userDetails.BirthDate);
            Assert.AreEqual(foundUser.Email, userDetails.Email);
            Assert.AreEqual(foundUser.FullName, userDetails.FullName);
            Assert.AreEqual(foundUser.PhoneNumber, userDetails.PhoneNumber);
            Assert.AreEqual(foundUser.Qualification, userDetails.Qualification);
            Assert.AreEqual(foundUser.RegisteredDate, userDetails.RegisteredDate);
            Assert.AreEqual(foundUser.UserName, userDetails.Username);


            Assert.IsTrue(userDetails.IsPersonnel);
            Assert.IsFalse(userDetails.IsAdmin);
            Assert.IsFalse(userDetails.IsDoctor);
            Assert.IsFalse(userDetails.Is2FAEnabled);
            Assert.IsFalse(userDetails.IsEmailVerified);
        }