Exemplo n.º 1
0
        public async Task Calculate_Profit_Sharing_Should_Be_Ok()
        {
            double availableValue = 400000;

            var participacoesCount = 2;

            var employeeOne = new Employee
            {
                AdmissionDate = new DateTime(2015, 01, 22),
                Department    = "Serviços Gerais",
                GrossSalary   = 120356,
                Name          = "João",
                Registration  = 1234324,
                Role          = "Auxiliar de contábilidade"
            };


            var employeeTwo = new Employee
            {
                AdmissionDate = new DateTime(2010, 11, 9),
                Department    = "Tecnologia",
                GrossSalary   = 9900,
                Name          = "João",
                Registration  = 1234324,
                Role          = "Suporte técnico"
            };

            IEnumerable <Employee> employees = new Employee[]
            {
                employeeOne,
                employeeTwo
            };

            employeeServiceMock.Setup(e => e.GetAll()).Returns(Task.FromResult(employees));

            double profitSharingFakeEmployeeOne = 29999;
            double profitSharingFakeEmployeeTwo = 324324;

            string totalDistribuidoExpected          = "R$ 354.323,00";
            string totalDisponibilizadoExpected      = "R$ 400.000,00";
            string saldoTotalDisponibilizadoExpected = "R$ 45.677,00";

            profitSharingCalculatorMock.Setup(p => p.GetProfitSharing(employeeOne)).Returns(profitSharingFakeEmployeeOne);
            profitSharingCalculatorMock.Setup(p => p.GetProfitSharing(employeeTwo)).Returns(profitSharingFakeEmployeeTwo);

            ProfitSharingResult profitSharingResult = await profitSharingService.GetProfitSharingResult(availableValue);

            profitSharingResult.Participacoes.Should().HaveCount(participacoesCount);
            profitSharingResult.Total_De_Funcionarios.Should().Be(participacoesCount.ToString());
            profitSharingResult.Total_Distribuido.Should().Be(totalDistribuidoExpected);
            profitSharingResult.Total_Disponibilizado.Should().Be(totalDisponibilizadoExpected);
            profitSharingResult.Saldo_Total_Disponibilizado.Should().Be(saldoTotalDisponibilizadoExpected);
            employeeServiceMock.Verify(e => e.GetAll(), Times.Once);
            employeeServiceMock.VerifyNoOtherCalls();
            profitSharingCalculatorMock.Verify(p => p.GetProfitSharing(employeeOne), Times.Once);
            profitSharingCalculatorMock.Verify(p => p.GetProfitSharing(employeeTwo), Times.Once);
            profitSharingCalculatorMock.VerifyNoOtherCalls();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get(double availableValue)
        {
            try
            {
                ProfitSharingResult profitSharingResult = await profitSharingService.GetProfitSharingResult(availableValue);

                return(Ok(profitSharingResult));
            }
            catch (InsufficientValueProfitSharingException ex)
            {
                return(BadRequest(ex.Message));
            }
        }