Created
January 15, 2017 20:21
-
-
Save adrianbontea/a148c26c1eabda9b8c0f668645da0852 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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