public void IsTrue2_FalseAsConditionArgument_ShouldThrowInternalErrorException() { Throws(() => { Assumes.IsTrue(false, "Message"); }); }
private static Exception CreateInternalErrorException(string message) { Exception exception = null; try { Assumes.IsTrue(false, message); } catch (Exception ex) { exception = ex; } Assert.IsNotNull(exception); return(exception); }
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); }
internal static void NotNullOrEmpty <T>(T[] values) { Assumes.NotNull(values); Assumes.IsTrue(values.Length > 0); }
public void IsTrue2_TrueAsConditionArgument_ShouldNotThrow() { Assumes.IsTrue(true, "Message"); }
public void IsTrue1_TrueAsConditionArgument_ShouldNotThrow() { Assumes.IsTrue(true); }