public override IEnumerable <Result> Execute(Release release)
        {
            var helper = new StageHelper();
            var res    = new List <Result>();
            var units  = release.GetAnalysisUnits(i => i.Type == "Action" || i.Type == "Anchor");
            var stages = units.Select(i => i.Stage).ToList();
            var mark   = GetQueueStages(stages.Where(i => i.Type == "Action"), "Mark Exception").ToList();
            var tag    = GetQueueStages(stages.Where(i => i.Type == "Action"), "Tag Item").ToList();

            foreach (var ac in mark)
            {
                //no tag for the mark exception
                var tagFound = tag.Any(i => {
                    var next = helper.GetNextStage(i.OnSuccess, stages);
                    return
                    (!string.IsNullOrWhiteSpace(i.OnSuccess) &&
                     next != null && next.Id == ac.Id);
                });
                if (!tagFound)
                {
                    res.Add(FromStageAnalysis(units.First(i => i.Stage.Id == ac.Id),
                                              ResultType.Error, string.Format(@"Mark exception stage ""{0}"" requires that item has the exception labeled", ac.Name),
                                              ""
                                              ));
                }
            }
            return(res);
        }
        public dynamic Create(RuleProfile profile, IEnumerable <IRule> rules, IEnumerable <Result> results, Release release, bool groupRuleResult)
        {
            var units  = release.GetAnalysisUnits();
            var result = new
            {
                RunProperties = GetRunProperites(release, profile),
                RuleResults   = GetRuleResults(rules, results),
                DataItems     = GetVariableData(units),
                Actions       = units.Where(i => i.Stage.Type == "Action").Select(i => new {
                    ParentType = i.ParentType,
                    Parent     = i.ParentName,
                    Page       = i.Page,
                    Stage      = i.Stage.Name,
                    Object     = ((ActionStage)i.Stage).Resource.Object,
                    Action     = ((ActionStage)i.Stage).Resource.Action
                }),
                Elements    = GetElements(release),
                Exceptions  = GetExceptionDetails(units),
                Navigations = GetNavigateStages(units),
                Results     = groupRuleResult ? GetGroupedRules(rules, results) : results.Select(i => new {
                    RuleName  = i.RuleName,
                    Type      = i.Type,
                    Message   = i.Message,
                    Scope     = i.Scope,
                    Parent    = i.Parent,
                    Page      = i.Page,
                    Stage     = i.Stage,
                    StageType = i.StageType,
                    StageId   = i.StageId
                }).ToList(),
            };

            return(result);
        }
        public override IEnumerable <Result> Execute(Release release)
        {
            var helper         = new StageHelper();
            var res            = new List <Result>();
            var units          = release.GetAnalysisUnits();
            var navigateStages = FilterStagesToAnalize(release.GetAnalysisUnits());

            foreach (var u in navigateStages)
            {
                var stages = helper.FilterStagesByPage(u, units);
                if (!helper.HasAnImediatePreviousWait(u.Stage, units.Where(i => i.PageId == u.PageId).Select(i => i.Stage)))
                {
                    res.Add(FromStageAnalysis(u, ResultType.Error,
                                              string.Format("{0} stage {1} is not preceeded by a proper wait stage", u.Stage.Type, u.Stage.Name), ""));
                }
            }
            return(res);
        }
Esempio n. 4
0
        public override IEnumerable <Result> Execute(Release release)
        {
            var waits = release.GetAnalysisUnits()
                        .Where(i => i.ParentType == "Object" && i.Stage.Type == "WaitStart" &&
                               ((WaitStartStage)(i.Stage)).IsArbitraryWait).ToList();

            return(waits.Select(i => FromStageAnalysis(i,
                                                       ResultType.Warning, string.Format("Please check stage {0} for arbitrary waits", i.Stage.Name), "")));
        }
Esempio n. 5
0
        public override IEnumerable <Result> Execute(Release release)
        {
            var res   = new List <Result>();
            var units = release.GetAnalysisUnits();

            VerifyMainPages(res, release.Processes, "Process");
            VerifyMainPages(res, release.Processes, "Object");
            VerifyStartAndEnd(res, units);
            return(res);
        }
Esempio n. 6
0
            private string SaveReport(RuleProfile profile, IEnumerable <IRule> rules, IEnumerable <Result> results, Release release)
            {
                var fileName = (!string.IsNullOrWhiteSpace(release.Name) ? release.Name : @"result") + ".xlsx";

                //var fileInfo = new FileInfo(fileName);
                release.GetAnalysisUnits();
                ExcelOutputGenerator excelGenerator = new ExcelOutputGenerator();

                excelGenerator.CreateReport(Path.GetDirectoryName(_fileName) + @"\" + fileName, profile, rules, results, release);
                return(fileName);
            }
        public override IEnumerable <Result> Execute(Release release)
        {
            var exclusions = GetExlusions().Split(",".ToArray());
            var units      = release.GetAnalysisUnits().Where(i =>
                                                              !exclusions.Contains(i.Stage.Type) &&
                                                              Regex.IsMatch(i.Stage.Name.ToLowerInvariant(), string.Format(_exp, i.Stage.Type.ToLowerInvariant()))).ToList();
            var res = units.Select(i => FromStageAnalysis(i, ResultType.Error,
                                                          string.Format("Stage name {0} is not a proper name", i.Stage.Name), "")).ToList();

            return(res);
        }
Esempio n. 8
0
        public override IEnumerable <Result> Execute(Release release)
        {
            var res    = new List <Result>();
            var errors = release.GetAnalysisUnits()
                         .Where(i => i.Page != "Main" && i.Stage.Type == "Data" && !((DataItem)i.Stage).IsPrivate).ToList();

            foreach (var error in errors)
            {
                res.Add(FromStageAnalysis(error, ResultType.Error, string.Format("Global Data Items need to be in the main or initialize page"), ""));
            }
            return(res);
        }
        public override IEnumerable <Result> Execute(Release release)
        {
            var items = release.GetAnalysisUnits()
                        .Where(i => i.Stage.Type == "Data")
                        .Where(
                i => {
                var item = ((DataItem)(i.Stage));
                return(item.HasInitialValue &&
                       string.IsNullOrWhiteSpace(item.Exposure));
            }).ToList();

            return(items.Select(i => FromStageAnalysis(i, ResultType.Warning,
                                                       string.Format("Data item {0} is initialized", i.Stage.Name),
                                                       "Data items should not be initialized")));
        }
        public override IEnumerable<Result> Execute(Release release)
        {
            var helper = new StageHelper();
            var res = new List<Result>();
            var units = release.GetAnalysisUnits();
            var readsAndWrites = units.Where(i => i.Stage.Type == "Read" || i.Stage.Type == "Write").ToList();
            foreach (var u in readsAndWrites)
            {

                if (HasExclusion(u.Stage)) continue;
                var stages = helper.FilterStagesByPage(u, units);
                if (!helper.HasAnImediatePreviousWait(u.Stage, units.Where(i => i.PageId == u.PageId).Select(i => i.Stage)))
                    res.Add(FromStageAnalysis(u, ResultType.Error,
                        string.Format("{0} stage {1} is not preceeded by a proper wait stage", u.Stage.Type, u.Stage.Name), ""));
            }
            return res;
        }
Esempio n. 11
0
        public static IEnumerable <object> GetRunProperites(Release release, RuleProfile profile)
        {
            var units = release.GetAnalysisUnits();
            var res   = new List <dynamic>
            {
                new { Parameter = "Run At UTC", Value = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss") },
                new { Parameter = "Run At Local Time", Value = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") },
                new { Parameter = "Run On Machine", Value = Environment.MachineName },
                new { Parameter = "Run By User", Value = Environment.UserName },
                new { Parameter = "Profile Exclusions", Value = string.Join("*", profile.Exclusions.Select(i => i.Name)) },
                new { Parameter = "Package Name", Value = release.PackageName },
                new { Parameter = "Release Name", Value = release.Name },
                new { Parameter = "Object Count", Value = release.Objects.Count.ToString() },
                new { Parameter = "Process Count", Value = release.Processes.Count.ToString() },
                new { Parameter = "Total Stages", Value = units.Count().ToString() }
            };

            return(res);
        }
Esempio n. 12
0
        public override IEnumerable <Result> Execute(Release release)
        {
            var res   = new List <Result>();
            var units = release.GetAnalysisUnits();
            var navs  = units.Where(i => i.Stage.Type == "Navigate").ToList();

            foreach (var nav in navs)
            {
                var navStage = ((NavigateStage)nav.Stage);
                if (!navStage.Actions.Any(i => !string.IsNullOrWhiteSpace(i.Action) && i.Action == "Navigate"))
                {
                    continue;
                }
                if (!IsNextWait(navStage, units))
                {
                    res.Add(FromStageAnalysis(nav, ResultType.Error,
                                              string.Format("A navigation stage needs to follow a wait stage to control the flow"), ""));
                }
            }
            return(res);
        }
Esempio n. 13
0
        public override IEnumerable <Result> Execute(Release release)
        {
            var res   = new List <Result>();
            var units = release.GetAnalysisUnits();
            var waits = units.Where(i => i.Stage != null && i.Stage.Type == "WaitEnd").ToList();

            foreach (var wait in waits)
            {
                var ex = GetNextException(wait.Stage, units);
                if (ex == null)
                {
                    res.Add(FromStageAnalysis(wait, ResultType.Error,
                                              string.Format("Unable to find a exception after the timeout")
                                              , ""));
                }
                else if (!IsSystemException(ex))
                {
                    res.Add(FromStageAnalysis(wait, ResultType.Error,
                                              string.Format("Exception type after timeout should be a System Exception, current exception type is {0} with message {1}", ex.Details.Type, ex.Details.Detail)
                                              , ""));
                }
            }
            return(res);
        }