コード例 #1
0
ファイル: BaseTest.cs プロジェクト: vladkosarev/MiniProfiler
        public void AssertProfilersAreEqual(MiniProfiler mp1, MiniProfiler mp2)
        {
            Assert.AreEqual(mp1, mp2);
            AssertPublicPropertiesAreEqual(mp1, mp2);

            var timings1 = mp1.GetTimingHierarchy().ToList();
            var timings2 = mp2.GetTimingHierarchy().ToList();

            Assert.That(timings1.Count == timings2.Count);
            for (int i = 0; i < timings1.Count; i++)
            {
                var t1 = timings1[i];
                var t2 = timings2[i];
                Assert.AreEqual(t1, t2);

                Console.WriteLine();
                AssertPublicPropertiesAreEqual(t1, t2);

                if (!t1.HasSqlTimings && !t2.HasSqlTimings)
                {
                    continue;
                }

                Assert.NotNull(t1.SqlTimings);
                Assert.NotNull(t2.SqlTimings);

                for (int j = 0; j < t1.SqlTimings.Count; j++)
                {
                    var s1 = t1.SqlTimings[j];
                    var s2 = t2.SqlTimings[j];
                    Assert.AreEqual(s1, s2);

                    Console.WriteLine();
                    AssertPublicPropertiesAreEqual(s1, s2);

                    if (s1.Parameters == null && s2.Parameters == null)
                    {
                        continue;
                    }

                    Assert.NotNull(s1.Parameters);
                    Assert.NotNull(s2.Parameters);

                    for (int k = 0; k < s1.Parameters.Count; k++)
                    {
                        var p1 = s1.Parameters[k];
                        var p2 = s2.Parameters[k];
                        Assert.AreEqual(p1, p2);

                        Console.WriteLine();
                        AssertPublicPropertiesAreEqual(p1, p2);
                    }
                }
            }
        }