Esempio n. 1
0
        public AccountDto Build()
        {
            var fixture = new Fixture();

            Account = fixture.Build <AccountDto>()
                      .With(a => a.Email, RandomData.Email)
                      .With(a => a.PasswordHash, SecretHasher.GetStringHash(_password))
                      .With(a => a.Verified, _verified)
                      .With(a => a.AcceptTerms, true)
                      .With(a => a.Created, DateTime.UtcNow)
                      .With(a => a.IsSuperAdmin, _role == Role.Admin)
                      .With(a => a.InvitationCode, _invitationCode)
                      .With(a => a.InvitationCodeExpiry, _invitationExipry)
                      .With(a => a.ResetToken, _resetToken)
                      .With(a => a.ResetTokenExpires, _resetTokenExpiry)
                      .Create();

            _connection.AddAccount(Account);

            if (_role.HasValue && _role != Role.Admin && _libraryId.HasValue)
            {
                _connection.AddAccountToLibrary(Account, _libraryId.Value, _role.Value);
            }

            return(Account);
        }