Ejemplo n.º 1
0
        public async Task ShouldAddNewUserFromIdentityProvider()
        {
            var userResult = new CcgAccountUser()
            {
                id = Guid.NewGuid().ToString(), name = "Test"
            };

            _testUserService.SetUserResult(userResult);

            InviteNewUserAccountCommand command;

            using (var db = _dbHelper.GetDbContext())
            {
                command = new InviteNewUserAccountCommand()
                {
                    Email        = "*****@*****.**",
                    GivenName    = "asdf",
                    Surname      = "asdf",
                    SystemRoleId = db.SystemRoles.First(e => e.IsActive).Id
                };
            }

            await _handler.ExecuteAsync(command);

            using (var db = _dbHelper.GetDbContext())
            {
                var user = db.Users.Single();
                user.ShouldNotBeNull();
                user.NameIdentifier.ShouldEqual(userResult.id);
                user.IsActive.ShouldBeTrue();
                user.SystemRoleId.ShouldEqual(command.SystemRoleId);
                _emailSender.SentMessages.ShouldNotBeEmpty();
                _emailSender.SentMessages.Count().ShouldEqual(1);
                _emailSender.SentMessages.Any(e => e.Subject.Contains(Email.AccessTitle)).ShouldBeTrue();
            }
        }
Ejemplo n.º 2
0
 public void SetUserResult(CcgAccountUser user)
 {
     _userResult = user;
 }