Example #1
0
        public void SimpleExpressionTest()
        {
            //Arrange
            string evalExpr = "1+1";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual("2", result, "Simple Expression Test");
        }
Example #2
0
        public void SplitExpressionTest_ReturnsEmpty()
        {
            //Arrange
            string evalExpr       = "Split(\"My-Tesla-Test\",\"-\")(3)";
            string expectedResult = "";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "Split Expression Test");
        }
Example #3
0
        public void MonthExpressionTest()
        {
            //Arrange
            string evalExpr = "Month(Now)";

            //Act
            string result   = VBS.ExecuteVBSEval(evalExpr);
            string monthNum = DateTime.Now.Month.ToString();

            //Assert
            Assert.AreEqual(monthNum, result, "Month Expression Test");
        }
Example #4
0
        public void RTrimExpressionTest()
        {
            //Arrange
            string evalExpr       = "RTrim(\"  Hello  \")";
            string expectedResult = "  Hello";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "Trim Expression Test");
        }
Example #5
0
        public void MidExpressionTest_StartPointAndEndPoint()
        {
            //Arrange
            string evalExpr       = "Mid(\"MyTeslaTest\",3,5)";
            string expectedResult = "Tesla";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "MID Expression Test");
        }
Example #6
0
        public void DatePartExpressionTest_Month()
        {
            //Arrange
            string evalExpr = "DatePart(\"m\", Now)";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);
            string month  = DateTime.Now.Month.ToString();

            //Assert
            Assert.AreEqual(month, result, "DatePart Expression Test");
        }
Example #7
0
        public void DatePartExpressionTest_Year()
        {
            //Arrange
            string evalExpr = "DatePart(\"yyyy\", Now)";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);
            string year   = DateTime.Now.Year.ToString();

            //Assert
            Assert.AreEqual(year, result, "DatePart Expression Test");
        }
Example #8
0
        public void InStrExpressionTest_UsingDifferentStartingPositions2()
        {
            //Arrange
            string evalExpr       = "InStr(7, \"This is a beautiful day!\",\"i\")";
            string expectedResult = "16";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "InStr Expression Test");
        }
Example #9
0
        public void HourExpressionTest()
        {
            //Arrange
            string evalExpr = "Hour(Now)";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);
            string hour   = DateTime.Now.Hour.ToString();

            //Assert
            Assert.AreEqual(hour, result, "Hour Expression Test");
        }
Example #10
0
        public void YearExpressionTest()
        {
            //Arrange
            string evalExpr = "Year(Now)";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);
            string year   = DateTime.Now.Year.ToString();

            //Assert
            Assert.AreEqual(year, result, "Year Expression Test");
        }
Example #11
0
        public void MidExpressionTest_FullString()
        {
            //Arrange
            string evalExpr       = "Mid(\"MyTeslaTest\",1)";
            string expectedResult = "MyTeslaTest";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "MID Expression Test");
        }
Example #12
0
        public void SplitExpressionTest()
        {
            //Arrange
            string evalExpr       = "Split(\"My-TeslaTest\",\"-\")";
            string expectedResult = "My";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "MID Expression Test");
        }
Example #13
0
        public void ReplaceExpressionTest()
        {
            //Arrange
            string evalExpr       = "Replace(\"MyTeslaTest\",\"Tesla\",\"Toyota\")";
            string expectedResult = "MyToyotaTest";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "Replace Expression Test");
        }
Example #14
0
        public void RightExpressionTest()
        {
            //Arrange
            string evalExpr       = "Right(\"This is a beautiful day!\",10)";
            string expectedResult = "tiful day!";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "Right Expression Test");
        }
Example #15
0
        public void MinuteExpressionTest()
        {
            //Arrange
            string evalExpr = "Minute(Now)";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);
            string minute = DateTime.Now.Minute.ToString();

            //Assert
            Assert.AreEqual(minute, result, "Minute Expression Test");
        }
Example #16
0
        public void InStrExpressionTest_FindStringPos()
        {
            //Arrange
            string evalExpr       = "InStr(\"This is a beautiful day!\",\"beautiful\")";
            string expectedResult = "11";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);

            //Assert
            Assert.AreEqual(expectedResult, result, "InStr Expression Test");
        }
Example #17
0
        public void WeekdayExpressionTest()
        {
            //Arrange
            string evalExpr = "Weekday(Now)";

            //Act
            int result  = int.Parse(VBS.ExecuteVBSEval(evalExpr));
            int weekDay = (int)DateTime.Now.DayOfWeek + 1;

            //Assert
            Assert.AreEqual(weekDay, result, "Weekday Expression Test");
        }
Example #18
0
        public void NowExpressionTest()
        {
            //Arrange
            string evalExpr = "now";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);
            //12/31/2018 7:38:56 PM
            DateTime localDate = DateTime.Now;

            //Assert
            Assert.AreEqual(localDate.ToString(), result, "Simple Expression Test");
        }
Example #19
0
        public void NowExpressionTest()
        {
            //Arrange
            string evalExpr = "now";

            //Act
            string result = VBS.ExecuteVBSEval(evalExpr);
            //12/31/2018 7:38:56 PM
            DateTime localDate = DateTime.Parse(result);

            //Assert
            Assert.IsTrue(!string.IsNullOrEmpty(result), "result not empty");
            Assert.AreEqual(localDate.ToString(), result, "Now Expression Test");
        }
Example #20
0
        public override void Execute()
        {
            CalculateCondition(this.RunOnBusinessFlow, RunOnEnvironment, this);
            string rc = VBS.ExecuteVBSEval(ConditionCalculated.Trim());

            if (rc == "-1")
            {
                ConditionCalculated += " is True";
                this.Status          = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;
            }
            else
            {
                ConditionCalculated += " is False";
                this.Status          = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
            }
        }
Example #21
0
        public void IntExpressionTest()
        {
            //Arrange
            string evalExpr_1       = "Int(-6.13443)";
            string expectedResult_1 = "-7";
            string evalExpr_2       = "Int(6.83227)";
            string expectedResult_2 = "6";

            //Act
            string result_1 = VBS.ExecuteVBSEval(evalExpr_1);
            string result_2 = VBS.ExecuteVBSEval(evalExpr_2);

            //Assert
            Assert.AreEqual(expectedResult_1, result_1, "Int Expression Test");
            Assert.AreEqual(expectedResult_2, result_2, "Int Expression Test");
        }
Example #22
0
        public void InStrRevExpressionTest_FindLetterUsingDifferentStartPos()
        {
            //Arrange
            string evalExpr        = "InStrRev(\"This is a beautiful day!\",\"T\",-1,1)";
            string expectedResult  = "15";
            string evalExpr1       = "InStrRev(\"This is a beautiful day!\",\"T\",-1,0)";
            string expectedResult1 = "1";


            //Act
            string result  = VBS.ExecuteVBSEval(evalExpr);
            string result1 = VBS.ExecuteVBSEval(evalExpr1);

            //Assert
            Assert.AreEqual(expectedResult, result, "InStrRev Expression Test");
            Assert.AreEqual(expectedResult1, result1, "InStrRev Expression Test");
        }
Example #23
0
        public override void Execute()
        {
            // in case of CS need to deferantionate failure reason compilation issue/ bool issue/false result and show info ontop act.exinfo
            string csharpError = "";

            CalculateCondition(this.RunOnBusinessFlow, RunOnEnvironment, this);
            string rc = String.Empty;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && CalcEngineType.Equals(eCalcEngineType.VBS))
            {
                rc = VBS.ExecuteVBSEval(ConditionCalculated.Trim());
            }
            else
            {
                Boolean parsedValue;
                rc = CodeProcessor.GetEvaluteResult(ConditionCalculated.Trim(), out csharpError);
                if (Boolean.TryParse(rc.Trim(), out parsedValue))
                {
                    if (parsedValue)
                    {
                        rc = "-1";
                    }
                }
            }
            if (rc == "-1")
            {
                ConditionCalculated += " is True";
                this.Status          = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Passed;
                this.ExInfo          = ConditionCalculated;
            }
            else
            {
                ConditionCalculated += " is False";
                this.Status          = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Failed;
                this.Error           = ConditionCalculated;
                if (!string.IsNullOrEmpty(csharpError))
                {
                    this.ExInfo = csharpError;
                }
            }
            return;
        }
Example #24
0
        public void RoundExpressionTest()
        {
            //Arrange
            string evalExpr_1       = "Round(24.13278)";
            string expectedResult_1 = "24";
            string evalExpr_2       = "Round(24.75122)";
            string expectedResult_2 = "25";
            string evalExpr_3       = "Round(24.13278,2)";
            string expectedResult_3 = "24.13";

            //Act
            string result_1 = VBS.ExecuteVBSEval(evalExpr_1);
            string result_2 = VBS.ExecuteVBSEval(evalExpr_2);
            string result_3 = VBS.ExecuteVBSEval(evalExpr_3);

            //Assert
            Assert.AreEqual(expectedResult_1, result_1, "Round Expression Test");
            Assert.AreEqual(expectedResult_2, result_2, "Round Expression Test");
            Assert.AreEqual(expectedResult_3, result_3, "Round Expression Test");
        }
Example #25
0
 private void ReplaceVBSCalcWithValue(string p, string[] a)
 {
     try
     {
         string Expr = p.Replace("\r\n", "vbCrLf");
         Expr = Expr.Substring(1, Expr.Length - 2);
         Expr = Expr.Replace("VBS Eval=", "");
         //check whether the Expr contains Split.If yes the take user entered number and decreased it to -1
         if (p.Contains("{VBS Eval=Split("))
         {
             Expr = DecreaseVBSSplitFunIndexNumber(Expr);
         }
         string v = VBS.ExecuteVBSEval(@"" + Expr);
         mValueCalculated = mValueCalculated.Replace(p, v.ToString());
     }
     catch (Exception e)
     {
         //TODO: err
         mValueCalculated = mValueCalculated.Replace(p, "ERROR: " + e.Message);
     }
 }