Exemplo n.º 1
0
 public TransacaoService(ITransacaoRepository transacaoRepository, IContaService contaService, INotificador notificador)
     : base(transacaoRepository, notificador)
 {
     _transacaoRepository = transacaoRepository;
     _contaService        = contaService;
     _notificador         = notificador;
 }
Exemplo n.º 2
0
 public FuncionarioService(IFuncionarioRepository repository, IFuncionarioEnderecoRepository funcionarioEnderecoRepository
                           , IContaService iContaService)
 {
     base._repository = repository;
     _funcionarioEnderecoRepository = funcionarioEnderecoRepository;
     _iContaService = iContaService;
 }
Exemplo n.º 3
0
 public CorrenteController(IContaCorrenteRepository contaCorrenteRepository, IMapper mapper, IContaService contaCorrenteService, INotificador notificador)
 {
     _contaCorrenteRepository = contaCorrenteRepository;
     _mapper = mapper;
     _contaCorrenteService = contaCorrenteService;
     _notificador          = notificador;
 }
 public PoupancaController(IContaPoupancaRepository contaPoupancaRepository, IMapper mapper, IContaService contaService, INotificador notificador)
 {
     _contaPoupancaRepository = contaPoupancaRepository;
     _mapper       = mapper;
     _contaService = contaService;
     _notificador  = notificador;
 }
Exemplo n.º 5
0
 public ContaTest()
 {
     _contaRepository   = Substitute.For <IContaRepository>();
     _contaService      = new ContaService(_contaRepository);
     _contaApp          = new ContaAppService(_contaService);
     _cancellationToken = new CancellationToken();
     SetupRepository();
 }
 public ContaController(BaseControllerInjector injector,
                        IContaService contaService,
                        UserService userService)
     : base(injector)
 {
     _contaService = contaService;
     _userService  = userService;
 }
Exemplo n.º 7
0
 public ClienteAppService(IClienteRepository ClienteRepository,
                          IClienteService ClienteService, IContaService contaService,
                          IUnitOfWork uow) : base(uow)
 {
     _ClienteRepository = ClienteRepository;
     _ClienteService    = ClienteService;
     _contaService      = contaService;
 }
Exemplo n.º 8
0
 public LancamentoTest()
 {
     _lancamentoRepository = Substitute.For <ILancamentoRepository>();
     _contaRepository      = Substitute.For <IContaRepository>();
     _contaService         = new ContaService(_contaRepository);
     _lancamentoService    = new LancamentoService(_lancamentoRepository, _contaService);
     _lancamentoApp        = new LancamentoAppService(_lancamentoService);
     _cancellationToken    = new CancellationToken();
     SetupRepository();
 }
Exemplo n.º 9
0
 public ContasController(
     IContaService contaService,
     IMapper mapper,
     INotifier notifier,
     ILogger <ContasController> logger) : base(notifier)
 {
     _contaService = contaService;
     _mapper       = mapper;
     _logger       = logger;
 }
Exemplo n.º 10
0
 public LancamentoService(
     IContaService contaService,
     IContaRepository contaRepository,
     ILancamentoRepository lancamentoRepository,
     INotifier notifier) : base(notifier)
 {
     _contaService         = contaService;
     _contaRepository      = contaRepository;
     _lancamentoRepository = lancamentoRepository;
 }
Exemplo n.º 11
0
 public ContaController
 (
     IContaService contaService,
     IMapper mapper,
     INotificacaoEvent notificacaoEvent
 )
     : base(notificacaoEvent)
 {
     _contaService = contaService;
     _mapper       = mapper;
 }
Exemplo n.º 12
0
 public ContaAppService(IContaRepository contaRepository,
                        IContaService contaService,
                        ITransacoesRepository transacoesRepository,
                        ITransacaoService transacaoService,
                        IUnitOfWork uow) : base(uow)
 {
     _contaRepository      = contaRepository;
     _contaService         = contaService;
     _transacoesRepository = transacoesRepository;
     _transacaoService     = transacaoService;
 }
Exemplo n.º 13
0
        private static void ConfigurarServicos(string[] args)
        {
            IHost host = Host.CreateDefaultBuilder(args)
                         .ConfigureServices((_, services) =>
                                            services.AddDbContext <BankDbContext>(options => options.UseSqlite("Data Source=Bank.db")).AddScoped <IContaService, ContaService>()
                                            .AddScoped <IContaRepository, ContaRepository>()).Build();

            IServiceScope scope    = host.Services.CreateScope();
            var           provider = scope.ServiceProvider;

            contaService = provider.GetRequiredService <IContaService>();
        }
Exemplo n.º 14
0
 public ContaController
 (
     INotificador notificador,
     IUsuarioService usuarioService,
     IContaService contaService,
     AuthService authService
 ) : base(notificador)
 {
     _usuarioService = usuarioService;
     _contaService   = contaService;
     _authService    = authService;
 }
Exemplo n.º 15
0
        public async Task QuandoExecutarGetPost()
        {
            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.Post(contaDtoCreate)).ReturnsAsync(contaDtoCreateResult);
            _service = _serviceMock.Object;

            var result = await _service.Post(contaDtoCreate);

            Assert.NotNull(result);
            Assert.Equal(Name, result.Name);
            Assert.Equal(Description, result.Description);
        }
 public BancoDigitalQuery(IContaService contaService)
 {
     Name = "Query";
     Field <DecimalGraphType>("saldo",
                              arguments: new QueryArguments(new QueryArgument <IntGraphType> {
         Name = "conta"
     }),
                              resolve: context =>
     {
         var resultado = contaService.Saldo(context.GetArgument <int>("conta"));
         return(resultado.Resultado == ResultadoOperacao.enResultado.Sucesso ? resultado.Conta.Saldo : throw new ExecutionError(resultado.Mensagem));
     });
 }
Exemplo n.º 17
0
 public ClienteController
 (
     INotificador notificador,
     IClienteService clienteService,
     IClienteRepository clienteRepository,
     IUsuarioService usuarioService,
     IContaService contaService
 ) : base(notificador)
 {
     _clienteService    = clienteService;
     _clienteRepository = clienteRepository;
     _usuarioService    = usuarioService;
     _contaService      = contaService;
 }
Exemplo n.º 18
0
        public void TestInitialize()
        {
            var options = new DbContextOptionsBuilder <AccountDbContext>().Options;

            dbctx = new AccountDbContext(options);

            _contaService = new ContaService(new ContaRepository(dbctx), new Notifier());

            _lancamentoService = new LancamentoService(
                _contaService,
                new ContaRepository(dbctx),
                new LancamentoRepository(dbctx),
                new Notifier());
        }
 public CadastrosConfiguracoesController(IPessoaService pessoaService,
                                         IEmpresaService empresaService,
                                         IUsuarioService usuarioService,
                                         ICentroCustoService centroCustoService,
                                         IPlanoContaService planoContaService,
                                         IContaService contaService)
 {
     _pessoaService      = pessoaService;
     _empresaService     = empresaService;
     _usuarioService     = usuarioService;
     _centroCustoService = centroCustoService;
     _planoContaService  = planoContaService;
     _contaService       = contaService;
 }
Exemplo n.º 20
0
        public OperacaoService(IContaService contaService, ILancamentoService lancamentoService)
        {
            _contaService      = contaService;
            _lancamentoService = lancamentoService;

            try
            {
                Mapper.Initialize(cfg => {
                    cfg.CreateMap <Conta, ContaArgument>();
                    cfg.CreateMap <Operacao, OperacaoArgument>();
                });
            }
            catch (System.Exception)
            {
            }
        }
Exemplo n.º 21
0
 public OperacaoController(BaseControllerInjector injector,
                           UserService userService,
                           IContaService contaService,
                           Lazy <ISaqueService> saqueService,
                           Lazy <IDepositoService> depositoService,
                           Lazy <ITransferenciaService> transferenciaService,
                           Lazy <IMovimentacaoService> movimentacaoService
                           )
     : base(injector)
 {
     _userService          = userService;
     _contaService         = contaService;
     _saqueService         = saqueService;
     _depositoService      = depositoService;
     _transferenciaService = transferenciaService;
     _movimentacaoService  = movimentacaoService;
 }
Exemplo n.º 22
0
        public OperacaoService(IContaService contaService, ILancamentoService lancamentoService)
        {
            _contaService      = contaService;
            _lancamentoService = lancamentoService;

            try
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap <ContaCorrente, Params.ContaCorrente>();
                    cfg.CreateMap <Operacao, Params.Operacao>();
                });
            }
            catch (System.Exception)
            {
            }
        }
 public MovimentacoesController(IPagarService pagarService,
                                IReceberService receberService,
                                IEmpresaService empresaService,
                                IContaService contaService,
                                IPessoaService pessoaService,
                                IPlanoContaService planoContaService,
                                ICentroCustoService centroCustoService,
                                ITransferenciaService transferenciaService)
 {
     _pagarService         = pagarService;
     _receberService       = receberService;
     _empresaService       = empresaService;
     _contaService         = contaService;
     _pessoaService        = pessoaService;
     _planoContaService    = planoContaService;
     _centroCustoService   = centroCustoService;
     _transferenciaService = transferenciaService;
 }
Exemplo n.º 24
0
        public MainTest()
        {
            try
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap <ContaCorrente, Params.ContaCorrente>();
                    cfg.CreateMap <Operacao, Params.Operacao>();
                });
            }
            catch (InvalidOperationException)
            {
                //Mapper está criado. ok.
            }

            _lancamentoRepository = new LancamentoRepository();
            _contaService         = new ContaService();
            _lancamentoService    = new LancamentoService(_contaService, _lancamentoRepository);
        }
Exemplo n.º 25
0
        public async Task QuandoExecutarDelete()
        {
            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.Delete(Id))
            .ReturnsAsync(true);
            _service = _serviceMock.Object;

            var deletado = await _service.Delete(Id);

            Assert.True(deletado);

            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.Delete(It.IsAny <Guid>()))
            .ReturnsAsync(false);
            _service = _serviceMock.Object;

            deletado = await _service.Delete(Guid.NewGuid());

            Assert.False(deletado);
        }
Exemplo n.º 26
0
 public RelatoriosController(IPessoaService pessoaService,
                             IEmpresaService empresaService,
                             IUsuarioService usuarioService,
                             ICentroCustoService centroCustoService,
                             IPlanoContaService PlanoContaService,
                             IContaService contaService,
                             ICaixaRepository caixaRepository,
                             IReceberRepository receberRepository,
                             IPagarRepository pagarRepository
                             )
 {
     _pessoaService      = pessoaService;
     _empresaService     = empresaService;
     _usuarioService     = usuarioService;
     _centroCustoService = centroCustoService;
     _PlanoContaService  = PlanoContaService;
     _contaService       = contaService;
     _caixaRepository    = caixaRepository;
     _receberRepository  = receberRepository;
     _pagarRepository    = pagarRepository;
 }
Exemplo n.º 27
0
        public async Task QuandoExecutarGet()
        {
            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.Get(Id)).ReturnsAsync(contaDto);
            _service = _serviceMock.Object;

            var result = await _service.Get(Id);

            Assert.NotNull(result);
            Assert.True(result.Id == Id);
            Assert.Equal(Name, result.Name);
            Assert.Equal(Description, result.Description);

            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(Task.FromResult((ContaDto)null));
            _service = _serviceMock.Object;

            var _record = await _service.Get(Id);

            Assert.Null(_record);
        }
Exemplo n.º 28
0
        public async Task QuandoExecutarGetAll()
        {
            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.GetAll()).ReturnsAsync(listaContaDto);
            _service = _serviceMock.Object;

            var result = await _service.GetAll();

            Assert.NotNull(result);
            Assert.True(result.Count() == 10);

            var _listResult = new List <ContaDto>();

            _serviceMock = new Mock <IContaService>();
            _serviceMock.Setup(m => m.GetAll()).ReturnsAsync(_listResult.AsEnumerable);
            _service = _serviceMock.Object;

            var _resultEmpty = await _service.GetAll();

            Assert.Empty(_resultEmpty);
            Assert.True(_resultEmpty.Count() == 0);
        }
        public BancoDigitalMutation(IContaService contaService)
        {
            Name = "Mutation";
            Field <ContaType>("depositar",
                              arguments: new QueryArguments(
                                  new QueryArgument <IntGraphType> {
                Name = "conta"
            },
                                  new QueryArgument <DecimalGraphType> {
                Name = "valor"
            }
                                  ),
                              resolve: context =>
            {
                var numeroConta = context.GetArgument <int>("conta");
                var valor       = context.GetArgument <decimal>("valor");
                var resultado   = contaService.Depositar(numeroConta, double.Parse(valor.ToString()));
                return(resultado.Resultado == ResultadoOperacao.enResultado.Sucesso ? resultado.Conta : throw new ExecutionError(resultado.Mensagem));
            });

            Field <ContaType>("sacar",
                              arguments: new QueryArguments(
                                  new QueryArgument <IntGraphType> {
                Name = "conta"
            },
                                  new QueryArgument <DecimalGraphType> {
                Name = "valor"
            }
                                  ),
                              resolve: context =>
            {
                var numeroConta = context.GetArgument <int>("conta");
                var valor       = context.GetArgument <decimal>("valor");
                var resultado   = contaService.Sacar(numeroConta, double.Parse(valor.ToString()));
                return(resultado.Resultado == ResultadoOperacao.enResultado.Sucesso ? resultado.Conta : throw new ExecutionError(resultado.Mensagem));
            });
        }
Exemplo n.º 30
0
        public MainTest()
        {
            try
            {
                Mapper.Initialize(cfg =>
                {
                    cfg.CreateMap <Conta, ContaArgument>();
                    cfg.CreateMap <Operacao, OperacaoArgument>();
                });
            }
            catch (InvalidOperationException)
            {
                //Mapper já inicializado!!! Segue a vida!
            }

            _lancamentoRepository = new LancamentoRepository();
            _contaService         = new ContaService();
            _lancamentoService    = new LancamentoService(_contaService, _lancamentoRepository);


            //CRIA AS CONTAS E GERA UM SALDO INICIAL PARA TESTE
            _dadosContaOrigem  = CriaConta("Santander", 2300, 10000001, 1, TipoConta.Corrente, 1000);
            _dadosContaDestino = CriaConta("Santander", 2300, 20000002, 3, TipoConta.Corrente, 1500);
        }