/// <summary>
        /// Checks an entity to see if it satisfies a class constraint
        /// </summary>
        /// <typeparam name="TClass">Type of class to check.</typeparam>
        /// <param name="expected">Expected object to use</param>
        /// <param name="candidate">Candidate object to use</param>
        /// <param name="objectName">Name to use, displayed in error messages to disambiguate</param>
        /// <returns>true if the instance pass, otherwise false.</returns>
        protected static bool CheckClass <TClass>(object expected, object candidate, string objectName)
            where TClass : class
        {
            if (expected is TClass)
            {
                CheckerFactory.Check(expected as TClass, candidate as TClass, objectName);
                return(true);
            }

            return(false);
        }
 /// <summary>
 /// Check the parent class of an entity
 /// </summary>
 /// <typeparam name="TClass">Type to cast the objects to.</typeparam>
 /// <param name="expected">Expected object to use</param>
 /// <param name="candidate">Candidate object to use</param>
 /// <param name="objectName">Name to use, displayed in error messages to disambiguate</param>
 protected static void CheckParentClass <TClass>(object expected, object candidate, string objectName)
     where TClass : class
 {
     CheckerFactory.CheckParent(expected as TClass, candidate as TClass, objectName);
 }
Esempio n. 3
0
 /// <summary>
 /// Verify that the contents of two lists of <see typeparamref="T" /> are the same
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="expectedList"></param>
 /// <param name="candidateList"></param>
 /// <param name="objectName"></param>
 protected void Check <T>(IEnumerable <T> expectedList, IEnumerable <T> candidateList, string objectName)
 {
     CheckerFactory.Check(expectedList, candidateList, objectName);
 }
Esempio n. 4
0
 /// <summary>
 /// Verify that the state of a couple of objects is the same
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <param name="expected"></param>
 /// <param name="candidate"></param>
 /// <param name="objectName"></param>
 protected void Check <TEntity>(TEntity expected, TEntity candidate, string objectName)
 {
     CheckerFactory.Check(expected, candidate, objectName);
 }