Exemple #1
0
        public void WebBrowser_AttachInterfaces_Invoke_Success()
        {
            object nativeActiveXObject = null;

            try
            {
                Type t = Type.GetTypeFromCLSID(new Guid("0002DF01-0000-0000-C000-000000000046"));
                nativeActiveXObject = Activator.CreateInstance(t);
            }
            catch (COMException)
            {
                // Windows doesn't have IE browser capability installed,
                // run 'Get-WindowsCapability -online' for more details
                //
                // xUnit doesn't support dynamic test skipping, https://github.com/xunit/xunit/issues/2073
                // just return. The test will be marked as success, but it is better than just fail.
                //
                //Skip.If(true, "Windows doesn't have IE browser capability installed");
                return;
            }

            using var control = new SubWebBrowser();
            control.AttachInterfaces(nativeActiveXObject);

            // Attach again.
            control.AttachInterfaces(nativeActiveXObject);
            control.DetachInterfaces();

            // Attach null.
            control.AttachInterfaces(null);
        }
Exemple #2
0
        public void WebBrowser_AttachInterfaces_Invoke_Success()
        {
            Type t = Type.GetTypeFromCLSID(new Guid("0002DF01-0000-0000-C000-000000000046"));
            var  nativeActiveXObject = Activator.CreateInstance(t);

            using var control = new SubWebBrowser();
            control.AttachInterfaces(nativeActiveXObject);

            // Attach again.
            control.AttachInterfaces(nativeActiveXObject);
            control.DetachInterfaces();

            // Attach null.
            control.AttachInterfaces(null);
        }
Exemple #3
0
 public void WebBrowser_AttachInterfaces_InvalidNativeActiveXObject_ThrowsInvalidCastException()
 {
     using var control = new SubWebBrowser();
     Assert.Throws <InvalidCastException>(() => control.AttachInterfaces(new object()));
 }