Ejemplo n.º 1
0
        public static void Equal <TEnumerable>(
            TEnumerable enumerableA,
            TEnumerable enumerableB) where TEnumerable : IEnumerable
        {
            var enumeratorA = enumerableA.GetEnumerator();
            var enumeratorB = enumerableB.GetEnumerator();

            var hasA = enumeratorA.MoveNext();
            var hasB = enumeratorB.MoveNext();

            var index = 0;

            while (hasA && hasB)
            {
                var currentA = enumeratorA.Current;
                var currentB = enumeratorB.Current;

                if (!object.Equals(currentA, currentB))
                {
                    Asserts.Fail($"Expected {currentA} to equal {currentB} at index ${index}.");
                }
                index++;

                hasA = enumeratorA.MoveNext();
                hasB = enumeratorB.MoveNext();
            }

            Asserts.True(!hasA && !hasB,
                         "Expected enumerables to be the same length.");
        }
Ejemplo n.º 2
0
 public static bool Equal(
     object?expected,
     object?actual,
     string?message = null)
 {
     if (expected?.Equals(actual) ?? false)
     {
         return(true);
     }
     Asserts.Fail(message ?? $"Expected {actual} to equal {expected}.");
     return(false);
 }
Ejemplo n.º 3
0
 public static bool True(bool value, string?message = null)
 => value || Asserts.Fail(message ?? "Expected to be true.");