Ejemplo 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);
        }
Ejemplo n.º 2
0
        public async Task DeveOrquestrarAsChamadasCorretamenteQuandoNaoHouveremServicosExternos()
        {
            _mapper.Setup(method => method.Map <InvestmentsDetailedViewModel>(It.IsAny <CustomerInvestments>())).Returns(new InvestmentsDetailedViewModel()
            {
                AmountTotal = 0, Investments = new List <InvestmentsDetailedViewModelItem>()
            });

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

            var result = await service.Get();

            Assert.IsTrue(result.Investments.Count == 0);
        }