Пример #1
0
        public void BadV8Deployment_NoNativeLibrary()
        {
            GC.Collect();

            V8Proxy.RunWithDeploymentDir("BadV8Deployment_NoNativeLibrary", () =>
            {
                var moduleNotFoundException       = new Win32Exception(126 /*ERROR_MOD_NOT_FOUND*/);
                TypeLoadException caughtException = null;

                try
                {
                    using (new V8ScriptEngine())
                    {
                    }
                }
                catch (TypeLoadException exception)
                {
                    caughtException = exception;
                }
                catch (TargetInvocationException exception)
                {
                    if (exception.InnerException is TypeLoadException typeLoadException)
                    {
                        caughtException = typeLoadException;
                    }
                    else
                    {
                        throw;
                    }
                }

                Assert.IsNotNull(caughtException);
                Assert.IsTrue(caughtException.Message.Contains(moduleNotFoundException.Message));
            });
        }
Пример #2
0
        public void BadV8Deployment_NoNativeLibrary()
        {
            V8Proxy.RunWithDeploymentDir("BadV8Deployment_NoNativeLibrary", () =>
            {
                var testException = new Win32Exception(126 /*ERROR_MOD_NOT_FOUND*/);
                TypeLoadException caughtException = null;

                try
                {
                    using (new V8ScriptEngine())
                    {
                    }
                }
                catch (TypeLoadException exception)
                {
                    caughtException = exception;
                }

                Assert.IsNotNull(caughtException);
                // ReSharper disable once PossibleNullReferenceException
                Assert.IsTrue(caughtException.Message.Contains(testException.Message));
            });
        }