Пример #1
0
 // The LINQ method Aggregate is the same as functional programming's "fold" or "reduce" function
 // Get all errors in a single string
 public string GetAllErrors() =>
 Validations.Aggregate("", (accumulator, validation) => accumulator + $",{validation.ErrorMessage}");
Пример #2
0
        public override string ToString()
        {
            var result = "\tPrimReq: (" + (InfoPage == null? "?" : InfoPage.Id.ToString(CultureInfo.CurrentCulture)) + ") " + GetRequestString(FiddlerSession) + "\n";

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

            result = ParametersToExtract.Aggregate(result,
                                                   (current, paramExtractor) =>
                                                   current + ("\t\tGetParameter: " + paramExtractor + "\n"));

            if (ParametersToExtract.Count > 0)
            {
                result += "\n";
            }

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

            if (InfoPage != null)
            {
                var tmp = InfoPage.GetParametersToExtract();
                if (tmp.Count > 0)
                {
                    result += string.Join("\n", tmp.Select(p => "\t\tGetParameter: " + p.ToString()).ToArray()) + "\n";
                }

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

                tmp = InfoPage.GetParametersToUse();
                if (tmp.Count > 0)
                {
                    result += string.Join("\n", tmp.Select(p => "\t\tUseParameter: " + p.ToString()).ToArray()) + "\n";
                }
            }

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


            //esto lo comento porque no se para que sirve y tira una excpecion cuando InfoPage es null
            //result = FollowRedirects.Aggregate(result,
            //                                   (current, request) =>
            //                                   current +
            //                                   ("\t\tRedir: " + request.RedirectType + ": " +
            //                                   "(" + (InfoPage == null ? "?" : InfoPage.Id.ToString(CultureInfo.CurrentCulture)) + ") " +
            //                                    GetRequestString(request.FiddlerSession) +
            //                                    "\n\t\t\t" +
            //                                    string.Join("\n\t\t\t", request.InfoPage.GetParametersToExtract().Select(p => "GetParameter: " + p.ToString()).ToArray()) +
            //                                    "\n\t\t\t" +
            //                                    string.Join("\n\t\t\t", request.InfoPage.GetParametersToUse().Select(p => "UseParameter: " + p.ToString()).ToArray()) +
            //                                    "\n"));

            if (FollowRedirects.Count > 0)
            {
                result += "\n";
            }

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

            //result = SecondaryRequests.Aggregate(result,
            //                                     (current, request) =>
            //                                     current + ("\t\tSecRec: " + GetRequestString(request) + "\n"));

            //if (SecondaryRequests.Count > 0)
            //{
            //    result += "\n";
            //}

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

            result = Validations.Aggregate(result,
                                           (current, validation) =>
                                           current + ("\t\tValidation: " + validation + "\n"));

            if (Validations.Count > 0)
            {
                result += "\n";
            }

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

            result += "Think time: " + ThinkTime + " millisecs.\n";

            return(result);
        }