public static SpecificationResult GenerateOverallSpecificationResult(
            bool overallResult, TraceMessageModifier traceModifier, [CanBeNull] params SpecificationResult[] results)
        {
            if (results == null || results.Length == 0)
            {
                return(null);
            }

            var totalSpecificationsCount = 0;
            var failedSpecifications     = new List <FailedSpecification>();
            var traces = new List <string>();

            foreach (var res in results)
            {
                totalSpecificationsCount += res.TotalSpecificationsCount;
                if (!overallResult)
                {
                    failedSpecifications.AddRange(res.FailedSpecifications);
                }
                if (!string.IsNullOrEmpty(res.Trace))
                {
                    traces.Add(res.Trace);
                }
            }

            var finalTrace = MergeTraces(traces, traceModifier);

            var mergeResult = new SpecificationResult(
                totalSpecificationsCount,
                overallResult,
                finalTrace,
                failedSpecifications.ToArray());

            return(mergeResult);
        }
        private static string MergeTraces([ItemNotNull] List <string> traces, TraceMessageModifier traceModifier)
        {
            if (!string.IsNullOrWhiteSpace(traceModifier.MergeFormat))
            {
                for (var i = 0; i < traces.Count; i++)
                {
                    if (i != 0 || traces.Count == 1)
                    {
                        traces[i] = string.Format(traceModifier.MergeFormat, traces[i]);
                    }
                }
            }
            var finalTrace = string.Join($" {traceModifier.Connector} ", traces);

            if (!string.IsNullOrWhiteSpace(traceModifier.OverallFormat) && !string.IsNullOrEmpty(finalTrace))
            {
                finalTrace = string.Format(
                    traceModifier.OverallFormat,
                    finalTrace);
            }

            return(finalTrace);
        }