Exemple #1
0
        public static void Ctor_String_Exception()
        {
            string message        = "bad rank";
            var    innerException = new Exception("Inner exception");
            var    exception      = new RankException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_RANK, innerException: innerException, message: message);
        }
        public static void Ctor_String_Type()
        {
            string message   = "security problem";
            var    exception = new SecurityException(message, typeof(SecurityExceptionTests));

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_SECURITY, message: message);
            Assert.Equal(typeof(SecurityExceptionTests), exception.PermissionType);
        }
Exemple #3
0
        public static void Ctor_String_Exception()
        {
            string message        = "something went wrong";
            var    innerException = new Exception("Inner exception");
            var    exception      = new Exception(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_EXCEPTION, innerException: innerException, message: message);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "security problem";
            var    innerException = new Exception("Inner exception");
            var    exception      = new SecurityException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_SECURITY, innerException: innerException, message: message);
        }
        public static void Ctor_String()
        {
            string message   = "type failed to load";
            var    exception = new TypeLoadException(message);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_TYPELOAD, message: message);
            Assert.Equal("", exception.TypeName);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "bad format";
            var    innerException = new Exception("Inner exception");
            var    exception      = new FormatException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_FORMAT, innerException: innerException, message: message);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "timeout";
            var    innerException = new Exception("Inner exception");
            var    exception      = new TimeoutException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_TIMEOUT, innerException: innerException, message: message);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "wrong type";
            var    innerException = new Exception("Inner exception");
            var    exception      = new InvalidCastException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_INVALIDCAST, innerException: innerException, message: message);
        }
Exemple #9
0
        public static void Ctor_String()
        {
            string message   = "this is not the file you're looking for";
            var    exception = new BadImageFormatException(message);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, message: message);
            Assert.Null(exception.FileName);
        }
        public static void Ctor_String_Int32()
        {
            string message   = "wrong type";
            int    errorCode = unchecked ((int)0x80424242);
            var    exception = new InvalidCastException(message, errorCode);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: errorCode, message: message);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "you cannot access this member";
            var    innerException = new Exception("Inner exception");
            var    exception      = new MemberAccessException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_MEMBERACCESS, innerException: innerException, message: message);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "the argument is wrong";
            var    innerException = new Exception("Inner exception");
            var    exception      = new ArgumentException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_ARGUMENT, innerException: innerException, message: message);
            Assert.Null(exception.ParamName);
        }
        public static void Ctor_String()
        {
            string argumentName = "theArgument";
            var    exception    = new ArgumentOutOfRangeException(argumentName);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_ARGUMENTOUTOFRANGE, validateMessage: false);
            Assert.Equal(argumentName, exception.ParamName);
            Assert.Null(exception.ActualValue);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "object disposed";
            var    innerException = new Exception("Inner exception");
            var    exception      = new ObjectDisposedException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_OBJECTDISPOSED, innerException: innerException, message: message);
            Assert.Equal("", exception.ObjectName);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "the argument is null";
            var    innerException = new Exception("Inner exception");
            var    exception      = new ArgumentNullException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: E_POINTER, innerException: innerException, message: message);
            Assert.Null(exception.ParamName);
        }
        public static void Ctor_String_Exception()
        {
            string message        = "the argument is out of range";
            var    innerException = new Exception("Inner exception");
            var    exception      = new ArgumentOutOfRangeException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_ARGUMENTOUTOFRANGE, innerException: innerException, message: message);
            Assert.Null(exception.ParamName);
            Assert.Null(exception.ActualValue);
        }
        public static void Ctor_String_String_Exception()
        {
            string message        = "this is not the file you're looking for";
            string fileName       = "file.txt";
            var    innerException = new Exception("Inner exception");
            var    exception      = new BadImageFormatException(message, fileName, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_BADIMAGEFORMAT, innerException: innerException, message: message);
            Assert.Equal(fileName, exception.FileName);
        }
        public static void Ctor_String_String()
        {
            string message    = "object disposed";
            string objectName = "theObject";
            var    exception  = new ObjectDisposedException(objectName, message);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_OBJECTDISPOSED, validateMessage: false);
            Assert.Equal(objectName, exception.ObjectName);
            Assert.Contains(message, exception.Message);
            Assert.Contains(objectName, exception.Message);
        }
        public static void Ctor_String_String()
        {
            string message      = "the argument is wrong";
            string argumentName = "theArgument";
            var    exception    = new ArgumentException(message, argumentName);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_ARGUMENT, validateMessage: false);
            Assert.Equal(argumentName, exception.ParamName);
            Assert.Contains(message, exception.Message);
            Assert.Contains(argumentName, exception.Message);
        }
        public static void Ctor_String_String()
        {
            string message      = "the argument is null";
            string argumentName = "theNullArgument";
            var    exception    = new ArgumentNullException(argumentName, message);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: E_POINTER, validateMessage: false);
            Assert.Equal(argumentName, exception.ParamName);
            Assert.Contains(message, exception.Message);
            Assert.Contains(argumentName, exception.Message);
        }
        public static void Ctor_String_Object_String()
        {
            string message       = "the argument is out of range";
            string argumentName  = "theArgument";
            int    argumentValue = Int32.MaxValue;
            var    exception     = new ArgumentOutOfRangeException(argumentName, argumentValue, message);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_ARGUMENTOUTOFRANGE, validateMessage: false);
            Assert.Equal(argumentName, exception.ParamName);
            Assert.Contains(message, exception.Message);
            Assert.Contains(argumentName, exception.Message);
            Assert.Contains(argumentValue.ToString(), exception.Message);
        }
        public static void Ctor_Empty()
        {
            var exception = new NotImplementedException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: E_NOTIMPL, validateMessage: false);
        }
        public static void Ctor_Empty()
        {
            var exception = new InvalidProgramException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_INVALIDPROGRAM, validateMessage: false);
        }
        public static void Ctor_Empty()
        {
            var exception = new KeyNotFoundException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_KEYNOTFOUND, validateMessage: false);
        }
        public static void Ctor_Empty()
        {
            var exception = new IndexOutOfRangeException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_INDEXOUTOFRANGE, validateMessage: false);
        }
Exemple #26
0
        public static void Ctor_Empty()
        {
            var exception = new ArrayTypeMismatchException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_ARRAYTYPEMISMATCH, validateMessage: false);
        }
        public static void Ctor_Empty()
        {
            var exception = new NotSupportedException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_NOTSUPPORTED, validateMessage: false);
        }
Exemple #28
0
        public static void Ctor_Empty()
        {
            var exception = new DivideByZeroException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_DIVIDEBYZERO, validateMessage: false);
        }
Exemple #29
0
        public static void Ctor_Empty()
        {
            var exception = new Exception();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_EXCEPTION, validateMessage: false);
        }
        public static void Ctor_Empty()
        {
            var exception = new OutOfMemoryException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: COR_E_OUTOFMEMORY, validateMessage: false);
        }