Beispiel #1
0
    public bool PosTest2()
    {
        bool   retVal = true;
        string strA;
        string ActualResult;

        TestLibrary.TestFramework.BeginScenario("PosTest2:normal string trim one");
        try
        {
            strA = TestLibrary.Generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            string strB  = spaceStrings[this.GetInt32(0, spaceStrings.Length)];
            string strA1 = strB + "H" + strA + "D" + strB;
            ActualResult = strA1.Trim();
            if (ActualResult.ToString() != "H" + strA.ToString() + "D")
            {
                TestLibrary.TestFramework.LogError("003", "normal string trim one when space is (" + strB.ToString() + ") ActualResult is not the ExpectResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Beispiel #2
0
    public bool PosTest2()
    {
        bool   retVal = true;
        string strA;

        char[] charA;
        string ActualResult;

        TestLibrary.TestFramework.BeginScenario("PosTest2:normal string trimStart char[] one");
        try
        {
            strA = TestLibrary.Generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            char char1   = this.GetChar(0, c_MINI_STRING_LENGTH);
            char char2   = this.GetChar(c_MINI_STRING_LENGTH, c_MINI_STRING_LENGTH + 68);
            char char3   = this.GetChar(c_MINI_STRING_LENGTH + 68, c_MAX_STRING_LENGTH / 2);
            char charEnd = this.GetChar(c_MAX_STRING_LENGTH / 2, c_MAX_STRING_LENGTH);
            charA = new char[] { char1, char2, char3 };

            string strA1 = char1.ToString() + char3.ToString() + strA + charEnd.ToString() + char1.ToString() + char3.ToString();
            ActualResult = strA1.TrimEnd(charA);
            if (ActualResult.ToString() != char1.ToString() + char3.ToString() + strA.ToString() + charEnd.ToString())
            {
                TestLibrary.TestFramework.LogError("003", "normal string trimEnd char[] one ActualResult is not the ExpectResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Beispiel #3
0
    public bool PosTest5()
    {
        bool   retVal = true;
        string strA;

        char[] charA;
        string ActualResult;

        TestLibrary.TestFramework.BeginScenario("PosTest5:normal string trimEnd char[] four");
        try
        {
            strA  = TestLibrary.Generator.GetString(-55, false, c_MINI_STRING_LENGTH, c_MAX_STRING_LENGTH);
            charA = new char[0];
            string strB  = spaceStrings[this.GetInt32(0, spaceStrings.Length)];
            string strA1 = strB + "H" + strB + strA + "D" + strB;
            ActualResult = strA1.TrimEnd(charA);
            if (ActualResult.ToString() != strB + "H" + strB + strA + "D")
            {
                TestLibrary.TestFramework.LogError("009", "normal string trimEnd char[] four ActualResult is not the ExpectResult");
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("010", "Unexpect exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
    public bool PosTest1()
    {
        bool   retVal = true;
        string strA;

        char[] ActualResult;

        TestLibrary.TestFramework.BeginScenario("PosTest1: empty string ToCharArray");
        try
        {
            strA         = string.Empty;
            ActualResult = strA.ToCharArray();
            char[] Expect = new char[0];
            if (ActualResult.ToString() != Expect.ToString() || ActualResult.Length != 0)
            {
                TestLibrary.TestFramework.LogError("001", "empty string ToCharArray ActualResult is not the ExpectResult");
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpected exception:" + e);
            retVal = false;
        }
        return(retVal);
    }
Beispiel #5
0
        public string MainPageWriter1()
        {
            //Main Page Writer
            string       body1  = string.Empty;
            StreamReader reader = new StreamReader("\\\\192.169.1.55\\Automation reports\\SCUF\\Report Repository\\Templates\\HTML Template\\MainPage_Template.html");

            body1 = reader.ReadToEnd();
            body1 = body1.Replace("{username}", Report.UserName);
            body1 = body1.Replace("{platform}", Report.OSName);
            body1 = body1.Replace("{URL}", Report.LURL);
            body1 = body1.Replace("{Application}", Report.ApplicationName);
            body1 = body1.Replace("{browsername}", Report.BrowserName.ToUpper());
            body1 = body1.Replace("{ProjectName}", Report.ProjName);

            for (int r = 0; r <= Report.g1 - 1; r++)
            {
                if (FinalResultList[r].ToString() == "Passed")
                {
                    PassedIterartion++;
                }
                if (FinalResultList[r].ToString() == "Failed")
                {
                    FailedIteration++;
                }
            }

            body1 = body1.Replace("{Iterations}", Report.g1.ToString());
            body1 = body1.Replace("{Passed}", PassedIterartion.ToString());
            body1 = body1.Replace("{Failed}", FailedIteration.ToString());
            double PassedPercent  = (double)PassedIterartion / Report.g1;
            double PassedPercent1 = PassedPercent * 180;
            double FailedPercent  = (double)FailedIteration / Report.g1;
            double FailedPercent1 = FailedPercent * 180;

            body1 = body1.Replace("{PassedPercent}", PassedPercent1.ToString());
            body1 = body1.Replace("{FailedPercent}", FailedPercent1.ToString());
            decimal passed     = System.Convert.ToDecimal(PassedIterartion);
            decimal total      = System.Convert.ToDecimal(Report.RowCount);
            decimal percentage = (passed / total) * 100;

            Percentage = System.Convert.ToInt16(percentage);
            body1      = body1.Replace("{Percentage}", Percentage.ToString());
            //body = body.Replace("{Maintable}", Maintable.ToString());

            for (int j = 0; j <= Report.RowCount - 1; j++)
            {
                var TestCaseDescription = TestCaseDescriptionList[j].ToString();
                var ExpectedStatus      = ExpectedStatusList[j].ToString();
                var ExpectedResulted    = ExpectedResultedList[j].ToString();
                var FinalResult         = FinalResultList[j].ToString();
                ActualResult = IterationStatus[j].ToString();
                var Filelocation = filelocation3List[j].ToString();

                body1 = body1.Replace("{TestDescription}", TestCaseDescription);
                body1 = body1.Replace("{ExpectedResult}", ExpectedResulted);
                body1 = body1.Replace("{SlNo}", (j + 1).ToString());

                string arcolour = "";
                string ecolour  = "";
                string acolour  = "";

                if (FinalResult == "Pass")
                {
                    acolour = "DARKGREEN";
                }
                else
                {
                    acolour = "MAROON";
                }

                if ((ExpectedStatus == "Pass"))
                {
                    ecolour = "DARKGREEN";
                }
                else
                {
                    ecolour = "MAROON";
                }

                if ((ActualResult.ToString() == "Pass"))
                {
                    arcolour = "DARKGREEN";
                }
                else
                {
                    arcolour = "MAROON";
                }
                string close = ">";


                string Filelocation1 = Regex.Replace(Filelocation, @"\\", @"\\");;
                string loc           = string.Format("\"{0}\"", "location.href='" + Filelocation1 + "'");

                //-----------------------For div1--------------------//
                string st      = "<div onclick=";
                string string1 = " style=";
                string string2 = string.Format("\"{0}\"", "height:140px; width:950px; margin-left: 15px; margin-top: 7px; border: 3px solid black; float : left; box-shadow: 5px 3px 3px 3px;");
                string s       = st + loc + string1 + string2 + close;
                Console.WriteLine(s);

                //-----------------------For div2--------------------//
                string string3 = "<div style=";
                string string4 = string.Format("\"{0}\"", "height:135px; width:110px; border: 1.5px solid white; float : left;");
                //close
                string string5 = "<h1>" + (j + 1).ToString() + "<h1></div>";
                string s1      = string3 + string4 + close + string5;
                Console.WriteLine(s1);

                //-----------------------For div3--------------------//
                string string6 = "<div style=";
                string string7 = string.Format("\"{0}\"", "height:100px; width:833px; border: 1.5px solid white; float : left");
                //Close
                string s2 = string6 + string7 + close;
                Console.WriteLine(s2);

                //-----------------------For Table--------------------//
                string string8  = "<table id = ";
                string string9  = string.Format("\"{0}\"", "mytable");
                string string10 = "align=";
                string string11 = string.Format("\"{0}\"", "left");
                string string12 = "cellpadding=";
                string string13 = string.Format("\"{0}\"", "1");
                string string14 = "style =";
                string string15 = string.Format("\"{0}\"", "width:825; height:90; border collapse: 1px solid gray; margin-left: 3; text-align: center; color: white;");
                //close
                string s3 = string8 + string9 + string10 + string11 + string12 + string13 + string14 + string15 + close;
                Console.WriteLine(s3);

                //-----------------------For Col--------------------//
                string string16 = "<col width=";
                string string17 = string.Format("\"{0}\"", "169");
                //Close
                string string18 = "<col width=";
                string string19 = string.Format("\"{0}\"", "auto");
                //Close
                string s4 = string16 + string17 + close + string18 + string19 + close;
                Console.WriteLine(s4);

                //-----------------------For start tbody--------------------//
                string string20 = "<tbody>";
                string s5       = string20;
                Console.WriteLine(s5);

                //-----------------------For 1st tr/td--------------------//
                string string21 = "<tr><td><b>Test Case Description</b></td><td>:</td><td>" + TestCaseDescription + "</td></tr>";
                string s6       = string21;
                Console.WriteLine(s6);

                //-----------------------For 2nd tr/td--------------------//
                string string22 = "<tr><td><b>Expected/Resulted</b></td><td>:</td><td>" + ExpectedResulted + "</td></tr>";
                string s7       = string22;
                Console.WriteLine(s7);

                //-----------------------For end tbody--------------------//
                string string23 = "</tbody>";
                string s8       = string23;
                Console.WriteLine(s8);

                //-----------------------For end table--------------------//
                string string24 = "</table>";
                string s9       = string24;
                Console.WriteLine(s9);

                //-----------------------For end div--------------------//
                string string25 = "</div>";
                string s10      = string25;
                Console.WriteLine(s10);

                //-----------------------For div4--------------------//
                string string26 = "<div style=";
                string string27 = string.Format("\"{0}\"", "height:35px; width:833px; border: 0px solid white; float : left");
                //Close
                string s11 = string26 + string27 + close;
                Console.WriteLine(s11);

                //-----------------------For div5--------------------//
                string string28 = "<div style=";
                string string29 = string.Format("\"{0}\"", "height:35px; width:277.5px; border: 1.5px solid white; float : left; background:" + arcolour + ";");
                //Close
                string string30 = "<h2>Automation Result : " + ActualResult + "</h2></div>";
                string s12      = string28 + string29 + close + string30;
                Console.WriteLine(s12);

                //-----------------------For div6--------------------//
                string string31 = "<div style=";
                string string32 = string.Format("\"{0}\"", "height:35px; width:277.5px; border: 1.5px solid white; float : left; background:" + ecolour + ";");
                //Close
                string string33 = "<h2>Expected Result : " + ExpectedStatus + "</h2></div>";
                string s13      = string31 + string32 + close + string33;
                Console.WriteLine(s13);

                //-----------------------For div6--------------------//
                string string34 = "<div style=";
                string string35 = string.Format("\"{0}\"", "height:35px; width:277.5px; border: 1.5px solid white; float : left; background:" + acolour + ";");
                //Close
                string string36 = "<h2>Final Result : " + FinalResult + "</h2></div>";
                string s14      = string34 + string35 + close + string36;
                Console.WriteLine(s14);

                //-----------------------For end div--------------------//
                string string37 = "</div>";
                string s15      = string37;
                Console.WriteLine(s15);

                //-----------------------For end div--------------------//
                string string38 = "</div>";
                string s16      = string38;
                Console.WriteLine(s16);

                arr.Add(s);
                arr.Add(s1);
                arr.Add(s2);
                arr.Add(s3);
                arr.Add(s4);
                arr.Add(s5);
                arr.Add(s6);
                arr.Add(s7);
                arr.Add(s8);
                arr.Add(s9);
                arr.Add(s10);
                arr.Add(s11);
                arr.Add(s12);
                arr.Add(s13);
                arr.Add(s14);
                arr.Add(s15);
                arr.Add(s16);

                if (Report.RowCount - 1 == j)
                {
                    Table = new StringBuilder();
                    foreach (string id in arr)
                    {
                        Table.Append(id + "");
                    }

                    body1 = body1.Replace("{Table}", Table.ToString());

                    ArrayList Date           = new ArrayList();
                    ArrayList Passed         = new ArrayList();
                    ArrayList Failed         = new ArrayList();
                    ArrayList PassPercent    = new ArrayList();
                    ArrayList TotalIteration = new ArrayList();
                    ArrayList passed1        = new ArrayList();
                    ArrayList failed1        = new ArrayList();
                    ArrayList pp             = new ArrayList();
                    ArrayList ti             = new ArrayList();

                    a2 = 0;

                    string[]  tr = File.ReadAllLines(loglocation);
                    ArrayList a  = new ArrayList(tr);
                    int       a1 = a.Count;
                    Thread.Sleep(1000);
                    for (int i = a1; i <= a1; i--)
                    {
                        int i1 = i;
                        Date.Add(a[i1 - 5]);
                        PassPercent.Add(a[i1 - 4]);
                        TotalIteration.Add(a[i1 - 3]);
                        Passed.Add(a[i1 - 2]);
                        Failed.Add(a[i1 - 1]);

                        i = i - 4;
                        if (i == 1)
                        {
                            break;
                        }
                    }

                    for (int sa = 0; sa <= Passed.Count - 1; sa++)
                    {
                        //-------------------------------------Pass Percent----------------------//

                        string[] res = Regex.Split(PassPercent[sa].ToString(), "-");
                        foreach (string res1 in res)
                        {
                            Console.WriteLine(res1);
                            pp.Add(res1);
                        }

                        //-------------------------------------Total Iteration----------------------//
                        string[] toti = Regex.Split(TotalIteration[sa].ToString(), "-");
                        foreach (string toti1 in toti)
                        {
                            Console.WriteLine(toti1);
                            ti.Add(toti1);
                        }

                        //-------------------------------------Passed----------------------//
                        string[] passs = Regex.Split(Passed[sa].ToString(), "-");
                        foreach (string passs1 in passs)
                        {
                            Console.WriteLine(passs1);
                            passed1.Add(passs1);
                        }

                        //-------------------------------------Failed----------------------//
                        string[] failll = Regex.Split(Failed[sa].ToString(), "-");
                        foreach (string failll1 in failll)
                        {
                            Console.WriteLine(failll1);
                            failed1.Add(failll1);
                        }

                        a2++;
                    }

                    string close1 = ">";
                    string cont   = "<div class=";
                    string cont1  = string.Format("\"{0}\"", "container");
                    string c      = cont + cont1 + close1;

                    sab = 1;
                    for (int sb = 0; sb <= PassPercent.Count - 1; sb++)
                    {
                        //-----------------------For h1--------------------//
                        string restring1 = string.Format("\"{0}\"", "Head2");
                        string restring2 = "<h2 class =" + restring1 + ">" + Date[sb] + "</h2>";
                        re = restring2;
                        Console.WriteLine(re);

                        //-----------------------For div2--------------------//
                        string restring3 = c + cont + string.Format("\"{0}\"", "skills");
                        // string string4 =  string3;
                        string restring5 = "style=";
                        string restring6 = string.Format("\"{0}\"", "width: " + pp[sb + sab].ToString() + "; background-color: #32CD32;");
                        //Close
                        string restring7 = PassPercent[sb] + "</div></div>";
                        re2 = restring3 + restring5 + restring6 + close1 + restring7;
                        Console.WriteLine(re2);

                        string restring61 = string.Format("\"{0}\"", "width:100%; background-color: #008080;");
                        string restring71 = TotalIteration[sb] + "</div></div>";
                        re3 = restring3 + restring5 + restring61 + close1 + restring71;
                        Console.WriteLine(re3);

                        int Pass_Iteration  = Convert.ToInt32(passed1[sb + sab]);
                        int Total_Iteration = Convert.ToInt32(ti[sb + sab]);
                        int Fail_Iteration  = Convert.ToInt32(failed1[sb + sab]);

                        double totalpass = (double)Pass_Iteration / Total_Iteration;
                        double tp        = totalpass * 100;
                        double totalfail = (double)Fail_Iteration / Total_Iteration;
                        double tf        = totalfail * 100;

                        string restring62 = string.Format("\"{0}\"", "width: " + tp.ToString() + "%; background-color: #2196F3;");
                        string restring72 = Passed[sb] + "</div></div>";
                        re4 = restring3 + restring5 + restring62 + close1 + restring72;
                        Console.WriteLine(re4);

                        string restring63 = string.Format("\"{0}\"", "width: " + tf.ToString() + "%; background-color: #f44336;");
                        string restring73 = Failed[sb] + "</div></div>";
                        re5 = restring3 + restring5 + restring63 + close1 + restring73;
                        Console.WriteLine(re5);

                        sab++;

                        arr2.Add(re);
                        arr2.Add(re2);
                        arr2.Add(re3);
                        arr2.Add(re4);
                        arr2.Add(re5);
                    }

                    Table2 = new StringBuilder();
                    foreach (string id in arr2)
                    {
                        Table2.Append(id + "");
                    }

                    body1 = body1.Replace("{Table2}", Table2.ToString());


                    reader.Close();
                    StreamWriter sw13 = new StreamWriter(folderpath + "\\OverallStatus.html");
                    sw13.WriteLine(body1);
                    sw13.Close();
                }
            }

            return(body1);
        }
Beispiel #6
0
        public void Final(int rowcount, string ReportLocation)
        {
            Reportlocation = ReportLocation;
            loglocation    = Reportlocation + "\\logfile.txt";
            IterationList.Add(Report.g1);
            ScenarioList.Add(Report.Scenario);
            TestCaseIDList.Add(Report.TestCaseID);
            ExpectedStatusList.Add(Report.ExpectedStatus);
            IterationStartTimeList.Add(Report.OverallStartTime);
            IterationEndTimeList.Add(Report.OverallEndTime);
            IterationDurationList.Add(Report.Iterationduration);
            TotalPassedStepsList.Add(Report.passedsteps);
            TotalFailedStepsList.Add(Report.failedsteps);
            StepsNotExecuted.Add(Report.totalsteps - Report.passedsteps - Report.failedsteps);
            TestCaseDescriptionList.Add(Report.TestCaseDescription);
            ExpectedResultedList.Add(Report.ExpectedResulted);
            filelocation3List.Add(Report.filelocation3);
            //PassedStepsCount.Add()

            if (Report.failedsteps == 0)
            {
                IterationStatus.Add("Pass");
            }
            else
            {
                IterationStatus.Add("Fail");
            }

            Maintable  = new StringBuilder();
            ChartTable = new StringBuilder();

            for (int j = 0; j <= Report.g1 - 1; j++)
            {
                var Iteration          = IterationList[j];
                var Scenario           = ScenarioList[j];
                var Testcaseid         = TestCaseIDList[j];
                var expectedstatus     = ExpectedStatusList[j];
                var IterationStartTime = IterationStartTimeList[j];
                var IterationEndTime   = IterationEndTimeList[j];
                var IterationDuration  = IterationDurationList[j];
                var TotalPassedSteps   = TotalPassedStepsList[j];
                var TotalFailedSteps   = TotalFailedStepsList[j];
                var StepsNotexecuted   = StepsNotExecuted[j];
                var Filelocation       = filelocation3List[j];

                ActualResult = IterationStatus[j].ToString();

                if (ActualResult == expectedstatus.ToString())
                {
                    FinalResult = "Pass";
                }
                else
                {
                    FinalResult = "Fail";
                }
                string loc = string.Format("\"{0}\"", Filelocation);

                var table1 = "<tr href=" + loc + "><td>" + Iteration + "</td><td>Iteration" + Iteration + "</td><td>" + Testcaseid + "</td><td> " + Scenario + "</td><td>" + IterationStartTime + "</td><td>" + IterationEndTime + "</td><td>" + IterationDuration + "</td><td>" + ActualResult.ToString() + "</td><td>" + expectedstatus.ToString() + "</td><td>" + FinalResult + "</td></tr>";
                ResultTable.Add(table1);


                //-----------------------------------------------------------------------------

                if (Report.RowCount == Report.g1)
                {
                    FinalResultList.Add(FinalResult);
                }
            }


            foreach (string id in ResultTable)
            {
                Maintable.Append(id + " ");
            }
        }