Exemple #1
0
        public void GetSalaryHour()
        {
            // Arrange
            decimal salary   = 70000;
            decimal expected = 100800000;

            // Act
            var     cal    = new CalculateHourlySalary();
            decimal result = cal.Calculate(salary);

            // Assert
            Assert.AreEqual(expected, result);
        }
        public ApiResponseOperations GetSalary(string contractTypeName, string salary)
        {
            ApiResponseOperations response = new ApiResponseOperations();

            try
            {
                decimal      result        = 0;
                decimal      sa            = Convert.ToDecimal(salary);
                const string contractHour  = "HourlySalaryEmployee";
                const string contractMonth = "MonthlySalaryEmployee";

                switch (contractTypeName)
                {
                case contractHour:
                    var calH = new CalculateHourlySalary();
                    result = calH.Calculate(sa);
                    break;

                case contractMonth:
                    var calM = new CalculateMonthlySalary();
                    result = calM.Calculate(sa);
                    break;
                }

                response.Data    = result;
                response.Message = "OK";
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Message = $"Error: {ex.Message}";
                response.Success = false;
            }

            return(response);
        }