public void Should_reload_remark_as_constant()
        {
            var attData = new AttendanceData {
                Remark = 1
            };

            Assert.AreEqual(2, calc.Calculate("iif(Remark = abss,2,1)", attData));
        }
Esempio n. 2
0
        public async Task <IActionResult> Calculate([FromBody] CalculateFormulaRequest postRequest)
        {
            var calc = new AttendanceCalculator();
            await calc.LoadCompanyStaticDataAsConstantAsync(mstaticRepo);

            var result = calc.Calculate(postRequest.Formula, await postRequest.Attandance.ToAttendanceDataAsync(mstaticRepo));

            return(Ok(new FormulaCalculatedResponse {
                Result = result
            }));
        }
        public void Should_load_attandance_load_formulas()
        {
            var attData = new AttendanceData {
                Regular = 1, Remark = 2
            };
            var attFormula = new AttendanceFormula {
                OT = "iif(Regular=2,1,2)", OT1 = "iif(Regular=1 && Remark=2,1,2)"
            };
            AttendanceCalculationResult result = calc.Calculate(attFormula, attData);

            Assert.AreEqual(2, result.OT);
            Assert.AreEqual(1, result.OT1);
        }
Esempio n. 4
0
        public void Should_calcuate_absent_day()
        {
            var attData = new AttendanceData {
                Classification = "CLS01", Regular = 1, Remark = 3
            };
            var attFormula = new AttendanceFormula {
                AbsentDay = mAbsenDayFormula, OT = "iif(Regular=2,1,2)", OT1 = "iif(Regular=1 && Remark=2,1,2)"
            };
            var classMock = new Mock <IAttendanceClassification>();

            classMock.Setup(m => m.LoadFormulasById("CLS01")).Returns(attFormula);
            AttendanceCalculationResult result = calc.Calculate(classMock.Object, attData);

            Assert.AreEqual(0.5, result.AbsentDay);
        }
        public void Should_load_attandance_load_formulas()
        {
            var attData = new AttendanceData {
                Classification = "CLS01", Regular = 1, Remark = 2
            };
            var attFormula = new AttendanceFormula {
                OT = "iif(Regular=2,1,2)", OT1 = "iif(Regular=1 && Remark=2,1,2)"
            };
            var classMock = new Mock <IAttendanceClassification>();

            classMock.Setup(m => m.LoadFormulasById("CLS01")).Returns(attFormula);
            AttendanceCalculationResult result = calc.Calculate(classMock.Object, attData);

            Assert.AreEqual(2, result.OT);
            Assert.AreEqual(1, result.OT1);
        }
Esempio n. 6
0
        public void Should_init_pisi_functions()
        {
            var statementFalse = "iif(0,1,2)";

            Assert.AreEqual(2, calc.Calculate(statementFalse));
        }
Esempio n. 7
0
        public void Should_load_attandance_data()
        {
            var attData = new AttendanceData {
                Regular = 1, Remark = 2
            };
            var statementFalse = "iif(Regular=2,1,2)";

            Assert.AreEqual(2, calc.Calculate(statementFalse, attData));
            var statementAttTrue = "iif(Regular=1 && Remark=2,1,2)";

            Assert.AreEqual(1, calc.Calculate(statementAttTrue, attData));
        }