Exemplo n.º 1
0
        public async Task DeveOrquestrarAsChamadasCorretamente()
        {
            var sampleInvestment = new FundosInvestment("Teste", 1000, 1000, DateTime.Now.AddYears(-1), DateTime.Now.AddYears(2));
            var sampleInvestmentDetailedViewModel = new InvestmentsDetailedViewModelItem {
                Name = "Teste", Amount = 1000, InvestedAmount = 1000, ExpireDate = DateTime.Now.AddYears(2)
            };
            var sampeInvestmentDTO = new InvestmentDTO()
            {
                Name = "Teste", Amount = 1000, InvestedAmount = 100, PurchaseDate = "2020-11-15T00:00:00", ExpireDate = "2022-11-15T00:00:00"
            };

            _investmentFactory.Setup(method => method.Create(It.IsAny <InvestmentDTO>())).Returns(sampleInvestment);

            _mapper.Setup(method => method.Map <InvestmentsDetailedViewModel>(It.IsAny <CustomerInvestments>())).Returns(new InvestmentsDetailedViewModel()
            {
                AmountTotal = 1000, Investments = new List <InvestmentsDetailedViewModelItem> {
                    sampleInvestmentDetailedViewModel
                }
            });

            _externalInvestmentSampleService.Setup(method => method.GetInvestments()).ReturnsAsync(new List <InvestmentDTO>()
            {
                sampeInvestmentDTO
            });
            _externalInvestmentServices.Add(_externalInvestmentSampleService.Object);

            InvestmentsService service = new InvestmentsService(_investmentFactory.Object, _mapper.Object, _externalInvestmentServices);

            var result = await service.Get();

            Assert.IsTrue(result.Investments.Count == 1);
        }
Exemplo n.º 2
0
        public void DeveRetirar6PorCentoDoValorInvestidoAoResgatarComMenosDe6MesesRestantesDoTempoPrevisto()
        {
            FundosInvestment fundosInvestment = new FundosInvestment("Teste", 1000, 1000, DateTime.Now.AddYears(-2), DateTime.Now.AddMonths(2));

            Assert.IsTrue(fundosInvestment.DrawAmount == 940); // 1000 - (1000 * 0.06) = 940
        }
Exemplo n.º 3
0
        public void DeveRetirar15PorCentoDoValorInvestidoAoResgatarComMaisDaMetadeDoTempoPrevistoCumprida()
        {
            FundosInvestment fundosInvestment = new FundosInvestment("Teste", 1000, 1000, DateTime.Now.AddYears(-2), DateTime.Now.AddYears(1));

            Assert.IsTrue(fundosInvestment.DrawAmount == 850); // 1000 - (1000 * 0.15) = 850
        }
Exemplo n.º 4
0
        public void DeveRetirar30PorCentoDoValorInvestidoAoResgatarComMenosDaMetadeDoTempoPrevistoCumprida()
        {
            FundosInvestment fundosInvestment = new FundosInvestment("Teste", 1000, 1000, DateTime.Now.AddYears(-1), DateTime.Now.AddYears(2));

            Assert.IsTrue(fundosInvestment.DrawAmount == 700); // 1000 - (1000 * 0.3) = 700
        }
        public void DeveRetirar15PorCentoDaRentabilidadeParaCalucularIR()
        {
            FundosInvestment fundosInvestment = new FundosInvestment("Teste", 800, 1000, DateTime.Today, DateTime.Today.AddYears(1));

            Assert.IsTrue(fundosInvestment.IncomeTax == 30); // (1000 - 800) * 0.15 = 30
        }