2021-07-12 21:31:46 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2024-04-09 12:53:23 +02:00
|
|
|
|
using ShareeBike.Model.User.Account;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2024-04-09 12:53:23 +02:00
|
|
|
|
namespace SharedBusinessLogic.Tests.Framework.Model.User.Account
|
2021-07-12 21:31:46 +02:00
|
|
|
|
{
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public class StoreMock : IStore
|
|
|
|
|
{
|
|
|
|
|
IAccount m_oAccount;
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Instantiates
|
|
|
|
|
/// - a dummy account to simulate a logged in user before end of last session
|
|
|
|
|
/// - an empty account to simulate no user logged in before end of last session
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="p_oAccount">If null no user is logged in.</param>
|
|
|
|
|
public StoreMock(IAccount p_oAccount = null)
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
m_oAccount = new ShareeBike.Model.User.Account.Account(p_oAccount ?? new EmptyAccount());
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public Task<IAccount> Load()
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
return Task.FromResult<IAccount>(new ShareeBike.Model.User.Account.Account(m_oAccount));
|
2022-09-06 16:08:19 +02:00
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public IAccount Delete(IAccount p_oAccount)
|
|
|
|
|
{
|
|
|
|
|
// Set member to empty.
|
|
|
|
|
m_oAccount = new EmptyAccount();
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
// Return empty account.
|
|
|
|
|
return new EmptyAccount();
|
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
|
2022-09-06 16:08:19 +02:00
|
|
|
|
public Task Save(IAccount p_oAccount)
|
|
|
|
|
{
|
2024-04-09 12:53:23 +02:00
|
|
|
|
m_oAccount = new ShareeBike.Model.User.Account.Account(p_oAccount);
|
2022-09-06 16:08:19 +02:00
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-12 21:31:46 +02:00
|
|
|
|
}
|