<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using FluentAssertions.Formatting;

namespace FluentAssertions.Execution
{
    /// <summary>
    /// Provides a fluent API for verifying an arbitrary condition.
    /// </summary>
    public class Verification
    {
        private readonly char[] blanks = new[] {'\r', '\n', ' ', '\t'};

        /// <summary>
        /// Represents the phrase that can be used in <see cref="FailWith"/> as a placeholder for the reason of an assertion.
        /// </summary>
        public const string ReasonTag = "{reason}";

        #region Private Definitions

        [ThreadStatic]
        private static string subjectName;

        private string reason;
        private bool succeeded;
        private bool useLineBreaks;

        [ThreadStatic]
        private static bool isCollecting;

        [ThreadStatic]
        private static List<string> failureMessages;

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="Verification"/> class.
        /// </summary>
        internal Verification()
        {
        }

        /// <summary>
        /// Indicates that every argument passed into <see cref="FailWith"/> is displayed on a separate line.
        /// </summary>
        public Verification UsingLineBreaks
        {
            get
            {
                useLineBreaks = true;
                return this;
            }
        }

        /// <summary>
        /// Gets or sets the name of the subject for the next verification.
        /// </summary>
        public static string SubjectName
        {
            get { return subjectName; }
            set { subjectName = value; }
        }

        public static void StartCollecting()
        {
            isCollecting = true;
        }

        public static void StopCollecting()
        {
            isCollecting = false;
            FailureMessages.Clear();
        }

        public static void ThrowIfAny(string context)
        {
            isCollecting = false;
            if (HasFailures)
            {
                string message = string.Join(Environment.NewLine, FailureMessages.ToArray()) + 
                    Environment.NewLine + 
                    context;

                AssertionHelper.Throw(message);
            }
        }

        public static bool HasFailures
        {
            get { return FailureMessages.Any(); }
        }

        /// <summary>
        /// Specify the condition that must be satisfied.
        /// </summary>
        /// <param name="condition">If <c>true</c> the verification will be succesful.</param>
        public Verification ForCondition(bool condition)
        {
            succeeded = condition;
            return this;
        }

        /// <summary>
        /// Specify the reason why you expect the condition to be <c>true</c>.<commit_msg>Added some missing comments on the Verification class.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using FluentAssertions.Formatting;

namespace FluentAssertions.Execution
{
    /// <summary>
    /// Provides a fluent API for verifying an arbitrary condition.
    /// </summary>
    public class Verification
    {
        private readonly char[] blanks = new[] {'\r', '\n', ' ', '\t'};

        /// <summary>
        /// Represents the phrase that can be used in <see cref="FailWith"/> as a placeholder for the reason of an assertion.
        /// </summary>
        public const string ReasonTag = "{reason}";

        #region Private Definitions

        [ThreadStatic]
        private static string subjectName;

        private string reason;
        private bool succeeded;
        private bool useLineBreaks;

        [ThreadStatic]
        private static bool isCollecting;

        [ThreadStatic]
        private static List<string> failureMessages;

        #endregion

        /// <summary>
        /// Initializes a new instance of the <see cref="Verification"/> class.
        /// </summary>
        internal Verification()
        {
        }

        /// <summary>
        /// Indicates that every argument passed into <see cref="FailWith"/> is displayed on a separate line.
        /// </summary>
        public Verification UsingLineBreaks
        {
            get
            {
                useLineBreaks = true;
                return this;
            }
        }

        /// <summary>
        /// Gets or sets the name of the subject for the next verification.
        /// </summary>
        public static string SubjectName
        {
            get { return subjectName; }
            set { subjectName = value; }
        }

        /// <summary>
        /// Prevents <see cref="FailWith"/> from throwing exceptions and collecting them until <see cref="StopCollecting"/>
        /// or <see cref="ThrowIfAny"/> is called.
        /// </summary>
        public static void StartCollecting()
        {
            isCollecting = true;
        }

        /// <summary>
        /// Discards any failures that happened since calling <see cref="StartCollecting"/> and switches back to the direct throwing mode.
        /// </summary>
        public static void StopCollecting()
        {
            isCollecting = false;
            FailureMessages.Clear();
        }

        /// <summary>
        /// Will throw a combined exception for any failures have been collected since <see cref="StartCollecting"/> was called.
        /// </summary>
        public static void ThrowIfAny(string context)
        {
            isCollecting = false;
            if (FailureMessages.Any())
            {
                string message = string.Join(Environment.NewLine, FailureMessages.ToArray()) + 
                    Environment.NewLine + 
                    context;

                AssertionHelper.Throw(message);
            }
        }

        /// <summary>
        /// Specify the condition that must be satisfied.
        /// </summary>
        /// <param name="condition">If <c>true</c> the verification will be succesful.</param>
        public Verification ForCondition(bool condition)
        {
            succeeded = condition;
            return this;
        }

        /// <summary>
        /// Specify the reason why you expect the condition to be <c>true</c>.
{'fraction_non_alphanumeric': 0.09842703628718268, 'fraction_numerical': 0.0, 'mean_word_length': 1.627659574468085, 'pattern_counts': {'":': 0, '<': 60, '<?xml version=': 0, '>': 60, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4038687', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1506, 'n_words': 499}