示例#1
0
 public void SetUp()
 {
     _checkingAccount       = ObjectMother.GetCheckingAccountValid();
     _mockRepositoryAccount = new Mock <ICheckingAccountRepository>();
     _mockRepositoryClient  = new Mock <IClientRepository>();
     _service = new CheckingAccountService(_mockRepositoryAccount.Object, _mockRepositoryClient.Object);
 }
示例#2
0
        public CheckingAccountApplicationService(
            IMapper mapper,
            ICheckingAccountService checkingAccountService)

        {
            _checkingAccountService = checkingAccountService;
            _mapper = mapper;
        }
 public PaymentApplicationService(
     IMapper mapper,
     IPaymentService paymentService,
     ICheckingAccountService checkingAccountService)
 {
     _paymentService         = paymentService;
     _mapper                 = mapper;
     _checkingAccountService = checkingAccountService;
 }
示例#4
0
        public CheckingAccountsController() : base()
        {
            var context               = new BankContext();
            var repository            = new CheckingAccountRepository(context);
            var repositoryClient      = new ClientRepository(context);
            var repositoryTransaction = new TransactionRepository(context);

            _accountsService = new CheckingAccountService(repository, repositoryClient, repositoryTransaction);
        }
        public TransferValidator(ICheckingAccountService checkingAccountService)
        {
            RuleFor(transfer => transfer.NumberFrom)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty()
            .NotNull()
            .Must(number => number > 0)
            .WithMessage("Número de conta origem inválido");

            RuleFor(transfer => transfer.NumberTo)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty()
            .NotNull()
            .Must(number => number > 0)
            .WithMessage("Número de conta destino inválido");

            RuleFor(transfer => transfer.NumberFrom)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEqual(t => t.NumberTo)
            .WithMessage("Conta origem e conta destino devem ser diferentes");

            RuleFor(transfer => transfer.Amount)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .NotEmpty()
            .NotNull()
            .Must(number => number > 0)
            .WithMessage("Valor de transferência deve ser maior que zero");

            RuleFor(transfer => transfer)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .Custom((transfer, context) =>
            {
                var checkingAccountFrom = checkingAccountService.GetByNumber(transfer.NumberFrom);
                if (checkingAccountFrom == null)
                {
                    context.AddFailure("Conta origem não encontrada");
                }
                if (checkingAccountFrom.UserId.ToString() != transfer.UserId)
                {
                    context.AddFailure("Conta origem não pertence ao usuário logado");
                }
            });

            RuleFor(transfer => transfer)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .Custom((transfer, context) =>
            {
                var checkingAccountFrom = checkingAccountService.GetByNumber(transfer.NumberTo);
                if (checkingAccountFrom == null)
                {
                    context.AddFailure("Conta destino não encontrada");
                }
            });
        }
示例#6
0
 public void SetUp()
 {
     AutoMapperInitializer.Reset();
     AutoMapperInitializer.Initialize();
     _checkingAccount         = ObjectMother.GetCheckingAccountValid();
     _checkingAccountRegister = Mapper.Map <CheckingAccountRegisterCommand>(_checkingAccount);
     _checkingAccountUpdate   = Mapper.Map <CheckingAccountUpdateCommand>(_checkingAccount);
     _checkingAccountRemove   = Mapper.Map <CheckingAccountRemoveCommand>(_checkingAccount);
     _mockRepositoryAccount   = new Mock <ICheckingAccountRepository>();
     _mockRepositoryClient    = new Mock <IClientRepository>();
     _service = new CheckingAccountService(_mockRepositoryAccount.Object, _mockRepositoryClient.Object);
 }
示例#7
0
 public TransactionService(ITransactionRepository transactionRepository, ICheckingAccountService checkingAccountService)
 {
     _transactionRepository  = transactionRepository;
     _checkingAccountService = checkingAccountService;
 }
示例#8
0
 public CheckingAccountsController(ICheckingAccountService checkingAccountService)
 {
     _accountsService = checkingAccountService;
 }
 public CheckingAccountService(ICheckingAccountService _checkingAccountService)
 {
     _checkingAccountService = checkingAccountService;
 }
示例#10
0
        public AccountControllerTest()
        {
            _checkingAccountServiceMock = Substitute.For <ICheckingAccountService>();

            _checkingAccountController = new AccountController(_checkingAccountServiceMock);
        }
示例#11
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CheckingAccountController(ICheckingAccountRepository checkingAccountRepository, ICheckingAccountService checkingAccountService, IMapper mapper)
 {
     _checkingAccountRepository = checkingAccountRepository;
     _checkingAccountService    = checkingAccountService;
     _mapper = mapper;
 }
示例#12
0
 public TransactionApplication(ICheckingAccountService checkingAccountService, ITransactionService transactionService)
 {
     _checkingAccountService = checkingAccountService;
     _transactionService     = transactionService;
 }
示例#13
0
 public CheckingAccountApplication(ICheckingAccountService checkingAccountService)
 {
     _checkingAccountService = checkingAccountService;
 }
 public AccountController(ICheckingAccountService checkingAccountService)
 {
     _checkingAccountService = checkingAccountService;
 }