This file contains hidden or 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
[Route("api/[controller]")] | |
public class AccountsController : Controller | |
{ | |
private readonly IDepositUseCase _depositUseCase; | |
private readonly Presenter _presenter; | |
public AccountsController( | |
IDepositUseCase depositUseCase, | |
Presenter presenter) | |
{ |
This file contains hidden or 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
public sealed class DepositUseCase : IDepositUseCase | |
{ | |
private readonly IAccountReadOnlyRepository _accountReadOnlyRepository; | |
private readonly IAccountWriteOnlyRepository _accountWriteOnlyRepository; | |
public DepositUseCase( | |
IAccountReadOnlyRepository accountReadOnlyRepository, | |
IAccountWriteOnlyRepository accountWriteOnlyRepository) | |
{ | |
_accountReadOnlyRepository = accountReadOnlyRepository; |
This file contains hidden or 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
public sealed class SSN | |
{ | |
private string _text; | |
const string RegExForValidation = @"^\d{6,8}[-|(\s)]{0,1}\d{4}$"; | |
public SSN(string text) | |
{ | |
if (string.IsNullOrWhiteSpace(text)) | |
throw new SSNShouldNotBeEmptyException("The 'SSN' field is required"); |
This file contains hidden or 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
[Fact] | |
public void Customer_Should_Be_Loaded() | |
{ | |
// | |
// Arrange | |
AccountCollection accounts = new AccountCollection(); | |
accounts.Add(Guid.Empty); | |
Customer customer = Customer.Load( | |
Guid.Empty, |
This file contains hidden or 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
public sealed class Customer : IEntity, IAggregateRoot | |
{ | |
public Guid Id { get; private set; } | |
public Name Name { get; private set; } | |
public SSN SSN { get; private set; } | |
public IReadOnlyCollection<Guid> Accounts | |
{ | |
get | |
{ | |
IReadOnlyCollection<Guid> readOnly = _accounts.GetAccountIds(); |
This file contains hidden or 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
public sealed class AccountCollection | |
{ | |
private readonly IList<Guid> _accountIds; | |
public AccountCollection() | |
{ | |
_accountIds = new List<Guid>(); | |
} | |
public IReadOnlyCollection<Guid> GetAccountIds() |
This file contains hidden or 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
public sealed class Account : IEntity, IAggregateRoot | |
{ | |
public Guid Id { get; private set; } | |
public Guid CustomerId { get; private set; } | |
public IReadOnlyCollection<ITransaction> GetTransactions() | |
{ | |
IReadOnlyCollection<ITransaction> readOnly = _transactions.GetTransactions(); | |
return readOnly; | |
} |
NewerOlder