Ejemplo n.º 1
0
        public async void FailedUpdateNewUserDuplicateEmailCase()
        {
            // When
            var newAdminUser = new AdminUser
            {
                Id    = new Guid("1d9a394c-60b8-4523-ab41-52b2936836c3").ToString(),
                Email = "*****@*****.**"
            };
            var adminUserRoleService = new AdminUserRoleService(_adminUserRepository, _adminRoleRepository);
            //Then
            ArgumentException ex = await Assert.ThrowsAsync <ArgumentException>(
                () => adminUserRoleService.UpdateAdminUser(newAdminUser));

            Assert.Contains("already used", ex.Message);
            Assert.Equal("email", ex.ParamName);

            using (var db = new GlownyShopContext(_options, _dbLogger.Object))
            {
                var admnUser = await db.AdminUsers.FindAsync(new Guid("1d9a394c-60b8-4523-ab41-52b2936836c3").ToString());

                Assert.NotNull(admnUser);
                Assert.Equal("*****@*****.**", admnUser.Email);
                Assert.Equal(new Guid("1d9a394c-60b8-4523-ab41-52b2936836c3").ToString(), admnUser.Id);
            }
        }
Ejemplo n.º 2
0
        public async void SuccesUpdateUserPasswordChanged()
        {
            // When
            var newAdminUser = new AdminUser
            {
                Id        = new Guid("1d9a394c-60b8-4523-ab41-52b2936836c3").ToString(),
                Email     = "*****@*****.**",
                FirstName = "First 1",
                LastName  = "Last 1",
                IsActive  = false,
                Password  = "******"
            };
            var adminUserRoleService = new AdminUserRoleService(_adminUserRepository, _adminRoleRepository);
            var adminUser            = await adminUserRoleService.UpdateAdminUser(newAdminUser);

            // Then
            Assert.NotNull(adminUser);
            using (var db = new GlownyShopContext(_options, _dbLogger.Object))
            {
                var admnUser = await db.AdminUsers.FindAsync(new Guid("1d9a394c-60b8-4523-ab41-52b2936836c3").ToString());

                Assert.NotNull(admnUser);
                Assert.Equal("*****@*****.**", admnUser.Email);
                Assert.Equal(new Guid("1d9a394c-60b8-4523-ab41-52b2936836c3").ToString(), admnUser.Id);
                Assert.Equal("First 1", admnUser.FirstName);
                Assert.Equal("Last 1", admnUser.LastName);
                Assert.Equal(false, admnUser.IsActive);
                Assert.NotEqual("0000", admnUser.Password);

                //clean up
                admnUser.Email     = "*****@*****.**";
                admnUser.FirstName = "Super";
                admnUser.LastName  = "Admin";
                admnUser.Password  = SecurityService.GenerateHashedPassword("P@ssw0rd");
                admnUser.IsActive  = true;

                db.SaveChanges();
            }
        }