Skip to content

Instantly share code, notes, and snippets.

@adrianbontea
Created January 15, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianbontea/a148c26c1eabda9b8c0f668645da0852 to your computer and use it in GitHub Desktop.
Save adrianbontea/a148c26c1eabda9b8c0f668645da0852 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using RoboBank.Account.Application.Ports;
using System.Text;
namespace RoboBank.Account.Application.Adapters.NetStandard
{
public class StubAccountRepository : IAccountRepository
{
private const string OwnCustomerId = "RoboBank";
private readonly IEnumerable<Domain.Account> _cache = new List<Domain.Account>
{
new Domain.Account
{
Id = "account1",
CustomerId ="customer1",
Currency = "USD",
Balance = 1000
} ,
new Domain.Account
{
Id = "account2",
CustomerId = "customer1",
Currency = "EUR",
Balance = 1000
}
};
public async Task<IEnumerable<Domain.Account>> GetByCustomerIdAsync(string customerId)
{
return _cache.Where(acc => acc.CustomerId == customerId).ToArray();
}
public async Task<Domain.Account> GetByIdAsync(string id)
{
return _cache.FirstOrDefault(acc => acc.Id == id);
}
public async Task<Domain.Account> GetOwnAccountByCurrencyAsync(string currency)
{
return _cache.FirstOrDefault(acc => acc.CustomerId == OwnCustomerId && acc.Currency == currency);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment