2026-03-06 07:14:57 -06:00
|
|
|
namespace FiscalOS.Infra.Tests.Data;
|
|
|
|
|
|
|
|
|
|
internal sealed class UserBuilder
|
|
|
|
|
{
|
|
|
|
|
private string _username = "username";
|
|
|
|
|
private string _password = "hashedPassword";
|
|
|
|
|
private EncryptedDataKey _dataKey = EncryptedDataKey.From(
|
|
|
|
|
"keyUsed",
|
|
|
|
|
"encryptedKey"
|
|
|
|
|
);
|
2026-03-08 07:18:27 -05:00
|
|
|
private readonly List<Institution> _instituions = [];
|
2026-03-06 07:14:57 -06:00
|
|
|
|
|
|
|
|
private UserBuilder()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static UserBuilder Create()
|
|
|
|
|
{
|
|
|
|
|
return new();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserBuilder WithUsername(string username)
|
|
|
|
|
{
|
|
|
|
|
_username = username;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserBuilder WithPassword(string password)
|
|
|
|
|
{
|
|
|
|
|
_password = password;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserBuilder WithDataKey(EncryptedDataKey key)
|
|
|
|
|
{
|
|
|
|
|
_dataKey = key;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserBuilder WithInstitution(Action<InstitutionBuilder>? action = null)
|
|
|
|
|
{
|
|
|
|
|
var ib = InstitutionBuilder.Create();
|
|
|
|
|
action?.Invoke(ib);
|
2026-03-08 07:18:27 -05:00
|
|
|
_instituions.Add(ib.Build());
|
2026-03-06 07:14:57 -06:00
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public User Build()
|
|
|
|
|
{
|
|
|
|
|
var user = User.From(
|
|
|
|
|
_username,
|
|
|
|
|
_password,
|
|
|
|
|
_dataKey
|
|
|
|
|
);
|
|
|
|
|
|
2026-03-08 07:18:27 -05:00
|
|
|
foreach (var institution in _instituions)
|
2026-03-06 07:14:57 -06:00
|
|
|
{
|
|
|
|
|
user.AddInstitution(institution);
|
2026-03-08 07:18:27 -05:00
|
|
|
|
|
|
|
|
foreach (var account in institution.Accounts)
|
|
|
|
|
{
|
|
|
|
|
user.AddAccount(account);
|
|
|
|
|
|
|
|
|
|
foreach (var transaction in account.Transactions)
|
|
|
|
|
{
|
|
|
|
|
user.AddTransaction(transaction);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-06 07:14:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return user;
|
|
|
|
|
}
|
|
|
|
|
}
|