예제 #1
0
 public void IsTrue2_FalseAsConditionArgument_ShouldThrowInternalErrorException()
 {
     Throws(() =>
     {
         Assumes.IsTrue(false, "Message");
     });
 }
예제 #2
0
        private static Exception CreateInternalErrorException(string message)
        {
            Exception exception = null;

            try
            {
                Assumes.IsTrue(false, message);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            return(exception);
        }
예제 #3
0
        internal static bool TryGetGenericInterfaceType(Type instanceType, Type targetOpenInterfaceType, out Type targetClosedInterfaceType)
        {
            // The interface must be open
            Assumes.IsTrue(targetOpenInterfaceType.IsInterface);
            Assumes.IsTrue(targetOpenInterfaceType.IsGenericTypeDefinition);
            Assumes.IsTrue(!instanceType.IsGenericTypeDefinition);

            // if instanceType is an interface, we must first check it directly
            if (instanceType.IsInterface &&
                instanceType.IsGenericType &&
                instanceType.UnderlyingSystemType.GetGenericTypeDefinition() == targetOpenInterfaceType.UnderlyingSystemType)
            {
                targetClosedInterfaceType = instanceType;
                return(true);
            }

            try
            {
                // Purposefully not using FullName here because it results in a significantly
                //  more expensive implementation of GetInterface, this does mean that we're
                //  takign the chance that there aren't too many types which implement multiple
                //  interfaces by the same name...
                Type targetInterface = instanceType.GetInterface(targetOpenInterfaceType.Name, false);
                if (targetInterface != null &&
                    targetInterface.UnderlyingSystemType.GetGenericTypeDefinition() == targetOpenInterfaceType.UnderlyingSystemType)
                {
                    targetClosedInterfaceType = targetInterface;
                    return(true);
                }
            }
            catch (AmbiguousMatchException)
            {
                // If there are multiple with the same name we should not pick any
            }

            targetClosedInterfaceType = null;
            return(false);
        }
예제 #4
0
 internal static void NotNullOrEmpty <T>(T[] values)
 {
     Assumes.NotNull(values);
     Assumes.IsTrue(values.Length > 0);
 }
예제 #5
0
 public void IsTrue2_TrueAsConditionArgument_ShouldNotThrow()
 {
     Assumes.IsTrue(true, "Message");
 }
예제 #6
0
 public void IsTrue1_TrueAsConditionArgument_ShouldNotThrow()
 {
     Assumes.IsTrue(true);
 }