public static void Ctor_String()
        {
            string message   = "this is not the file you're looking for";
            var    exception = new FileNotFoundException(message);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_FILENOTFOUND, message: message);
            Assert.Null(exception.FileName);
        }
        public static void From_HR()
        {
            int hr = HResults.COR_E_PATHTOOLONG;
            PathTooLongException exception = Marshal.GetExceptionForHR(hr) as PathTooLongException;

            Assert.NotNull(exception);
            ExceptionUtility.ValidateExceptionProperties(exception, hResult: hr, validateMessage: false);
        }
Ejemplo n.º 3
0
        public static void Ctor_String_Exception()
        {
            string message        = "That page was missing from the directory.";
            var    innerException = new Exception("Inner exception");
            var    exception      = new DirectoryNotFoundException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_DIRECTORYNOTFOUND, innerException: innerException, message: message);
        }
Ejemplo n.º 4
0
        public static void Ctor_String_String()
        {
            string message   = "this is not the file you're looking for";
            string fileName  = "file.txt";
            var    exception = new FileLoadException(message, fileName);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_FILELOAD, message: message);
            Assert.Equal(fileName, exception.FileName);
        }
Ejemplo n.º 5
0
        public static void Ctor_String_Exception()
        {
            string message        = "this is not the file you're looking for";
            var    innerException = new Exception("Inner exception");
            var    exception      = new FileLoadException(message, innerException);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_FILELOAD, innerException: innerException, message: message);
            Assert.Equal(null, exception.FileName);
        }
Ejemplo n.º 6
0
        public static void From_HR(int hr)
        {
            FileNotFoundException exception = Marshal.GetExceptionForHR(hr) as FileNotFoundException;

            Assert.NotNull(exception);

            // Don't validate the message.  Currently .NET Native does not produce HR-specific messages
            ExceptionUtility.ValidateExceptionProperties(exception, hResult: hr, validateMessage: false);
        }
        public static void Fom_HR(int hr)
        {
            var fileLoadException = Marshal.GetExceptionForHR(hr, new IntPtr(-1)) as FileLoadException;

            Assert.NotNull(fileLoadException);

            // Don't validate the message.  Currently .NET Native does not produce HR-specific messages
            ExceptionUtility.ValidateExceptionProperties(fileLoadException, hResult: hr, validateMessage: false);
            Assert.Null(fileLoadException.FileName);
        }
        public static void Ctor_Empty()
        {
            var exception = new DirectoryNotFoundException();

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_DIRECTORYNOTFOUND, validateMessage: false);
        }
Ejemplo n.º 9
0
        public static void Ctor_Empty()
        {
            var exception = new PathTooLongException();

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