Example #1
0
        /// <summary>
        /// Checks if the IEnumerable is naturally sorted
        /// </summary>
        /// <param name="context">context for the check</param>
        /// <param name="comparer">optional comparer</param>
        /// <typeparam name="T">enumerable type</typeparam>
        /// <returns>A check link</returns>
        public static ICheckLink <ICheck <T> > IsInAscendingOrder <T>(this ICheck <T> context, IComparer comparer = null) where T : IEnumerable
        {
            if (comparer == null)
            {
                comparer = new BasicComparer();
            }

            ExtensibilityHelper.BeginCheck(context).
            FailIfNull().
            Analyze((sut, test) =>
            {
                object previous = null;
                var index       = 0;
                var first       = true;
                foreach (var current in sut)
                {
                    if (!first)
                    {
                        if (comparer.Compare(previous, current) > 0)
                        {
                            test.Fail($"The {{checked}} is not in ascending order, whereas it should.{Environment.NewLine}At #{index}: [{previous.ToStringProperlyFormatted().DoubleCurlyBraces()}] comes after [{current.ToStringProperlyFormatted().DoubleCurlyBraces()}].");
                            return;
                        }
                    }
                    else
                    {
                        first = false;
                    }

                    previous = current;
                    index++;
                }
            }).
            OnNegate("The {checked} is in ascending order whereas it should not.").
            EndCheck();
            return(ExtensibilityHelper.BuildCheckLink(context));
        }
Example #2
0
 public CellProgress(string textPropertyName, string progressPropertyName)
     : base(textPropertyName)
 {
     this.progressPropertyName = progressPropertyName;
     comparer = new BasicComparer();
 }
Example #3
0
 public CellText(string propertyName)
     : base(propertyName)
 {
     comparer = new BasicComparer();
 }
Example #4
0
 public CellTextEnumerator()
     : base(null)
 {
     comparer = new BasicComparer();
 }