PageRenderTime 195ms CodeModel.GetById 100ms app.highlight 2ms RepoModel.GetById 79ms app.codeStats 13ms

/src/UnitTests/EnumerableExtensions.cs

http://github.com/philiplaureano/LinFu
C# | 32 lines | 25 code | 7 blank | 0 comment | 4 complexity | 88ae9dfb649f8cd3631c9b6ccf7ae569 MD5 | raw file
 1using System.Collections.Generic;
 2
 3namespace LinFu.UnitTests
 4{
 5    public static class EnumerableExtensions
 6    {
 7        public static bool AreEqualTo<T>(this IEnumerable<T> expectedArray, IEnumerable<T> actualArray)
 8        {
 9            var areEqual = true;
10
11            var expectedItems = new Queue<T>(expectedArray);
12            var actualItems = new Queue<T>(actualArray);
13
14            if (expectedItems.Count != actualItems.Count)
15                return false;
16
17            while (expectedItems.Count > 0)
18            {
19                var expectedItem = expectedItems.Dequeue();
20                var actualItem = actualItems.Dequeue();
21
22                if (Equals(expectedItem, actualItem))
23                    continue;
24
25                areEqual = false;
26                break;
27            }
28
29            return areEqual;
30        }
31    }
32}