コード例 #1
0
ファイル: LeibitComparer.cs プロジェクト: jannikbecker/leibit
        internal static void CompareDictionary <TKey, TValue>(IDictionary <TKey, List <TValue> > expected, IDictionary <TKey, List <TValue> > actual, LeibitComparer <TValue> comparer, string propertyName)
        {
            if (expected.Count != actual.Count)
            {
                Assert.Fail("Different dictionary size of property '{0}'. Expected: '{1}' Actual: '{2}'", propertyName, expected.Count, actual.Count);
            }

            foreach (var exp in expected)
            {
                if (!actual.ContainsKey(exp.Key))
                {
                    Assert.Fail("Element '{0}' could not be found in dictionary of property '{1}'.", exp.Key, propertyName);
                }

                CompareList(exp.Value, actual[exp.Key], comparer, propertyName);
            }
        }
コード例 #2
0
ファイル: LeibitComparer.cs プロジェクト: jannikbecker/leibit
        internal static void CompareList <TValue>(IEnumerable <TValue> expected, IEnumerable <TValue> actual, LeibitComparer <TValue> comparer, string propertyName)
        {
            if (expected.Count() != actual.Count())
            {
                Assert.Fail("Different list size of property '{0}'. Expected: '{1}' Actual: '{2}'", propertyName, expected.Count(), actual.Count());
            }

            foreach (var exp in expected)
            {
                var identifier = comparer.GetIdentifier(exp);
                var match      = actual.FirstOrDefault(x => comparer.GetIdentifier(x).Equals(identifier));

                if (match == null)
                {
                    Assert.Fail("Element '{0}' could not be found in list of property '{1}'.", exp, propertyName);
                }

                comparer.Compare(exp, match);
            }
        }