Esempio n. 1
0
        private void UpdateSpecFiles()
        {
            string[] fileContent;
            string   filterExp = "specfile='{0}' and Active=false";
            Int32    rindex;

            DataRow[]   drows;
            SpecDetails sdetails = new SpecDetails();

            LogInfo("Started updating Spec files");
            if (dt.Rows.Count > 0)
            {
                foreach (string spec in SpecFiles)
                {
                    fileContent = File.ReadAllLines(spec);
                    //Enable all specs by modifying all the describe and it statement
                    for (int r = 0; r < fileContent.Length; r++)
                    {
                        fileContent[r] = Regex.Replace(fileContent[r], @"\bxdescribe\b", "describe");
                        fileContent[r] = Regex.Replace(fileContent[r], @"\bxit\b", "it");
                    }

                    drows = dt.Select(string.Format(filterExp, spec));
                    foreach (DataRow drow in drows)
                    {
                        sdetails.Node = drow["Node"].ToString();
                        sdetails.Type = drow["Type"].ToString();

                        rindex = Array.FindIndex(fileContent, fi => fi.Contains(sdetails.Node));
                        if (rindex >= 0)
                        {
                            if (sdetails.Type.ToLower() == "suite")
                            {
                                string    innerfilter = "ParentId={0} and Active=true";
                                DataRow[] drs         = dt.Select(string.Format(innerfilter, drow["Id"]));
                                if (drs.Count() <= 0)
                                {
                                    fileContent[rindex] = Regex.Replace(fileContent[rindex], @"\bdescribe\b", "xdescribe");
                                }
                            }
                            else if (sdetails.Type.ToLower() == "spec")
                            {
                                fileContent[rindex] = Regex.Replace(fileContent[rindex], @"\bit\b", "xit");
                            }
                        }
                    }
                    //File.WriteAllText(spec, fileContent);
                    File.WriteAllLines(spec, fileContent);
                }
            }
            LogInfo("Sucessfully updated Spec files");
        }
Esempio n. 2
0
        private void UpdateSpecFiles()
        {
            string[] fileContent;
            string filterExp = "specfile='{0}' and Active=false";
            Int32 rindex;
            DataRow[] drows;
            SpecDetails sdetails = new SpecDetails();
            LogInfo("Started updating Spec files");
            if (dt.Rows.Count > 0)
            {
                foreach (string spec in SpecFiles)
                {
                    fileContent = File.ReadAllLines(spec);
                    //Enable all specs by modifying all the describe and it statement 
                    for (int r = 0; r < fileContent.Length; r++)
                    {
                        fileContent[r] = Regex.Replace(fileContent[r], @"\bxdescribe\b", "describe");
                        fileContent[r] = Regex.Replace(fileContent[r], @"\bxit\b", "it");
                    }

                    drows = dt.Select(string.Format(filterExp, spec));
                    foreach (DataRow drow in drows)
                    {
                        sdetails.Node = drow["Node"].ToString();
                        sdetails.Type = drow["Type"].ToString();

                        rindex = Array.FindIndex(fileContent, fi => fi.Contains(sdetails.Node));
                        if (rindex >= 0)
                        {
                            if (sdetails.Type.ToLower() == "suite")
                            {
                                string innerfilter = "ParentId={0} and Active=true";
                                DataRow[] drs = dt.Select(string.Format(innerfilter, drow["Id"]));
                                if (drs.Count() <= 0)
                                {
                                    fileContent[rindex] = Regex.Replace(fileContent[rindex], @"\bdescribe\b", "xdescribe");
                                }

                            }
                            else if (sdetails.Type.ToLower() == "spec")
                            {
                                fileContent[rindex] = Regex.Replace(fileContent[rindex], @"\bit\b", "xit");
                            }
                        }
                    }
                    //File.WriteAllText(spec, fileContent);
                    File.WriteAllLines(spec, fileContent);


                }
            }
            LogInfo("Sucessfully updated Spec files");
            
        }