Assert.Throws<PlatformNotSupportedException>(() => Marshal.BindToMoniker(null));
}
- [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetNative), nameof(PlatformDetection.IsNotWindowsNanoServer))]
+ [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetNative))]
[PlatformSpecific(TestPlatforms.Windows)]
[InlineData(null)]
[InlineData("")]
- public void BindToMoniker_NullOrEmptyMonikerName_ThrowsAnyException(string monikerName)
+ [InlineData("invalidName")]
+ public void BindToMoniker_InvalidArgument_ThrowsAnyException(string monikerName)
{
Assert.ThrowsAny<Exception>(() => Marshal.BindToMoniker(monikerName));
}
-
- [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotNetNative))]
- [PlatformSpecific(TestPlatforms.Windows)]
- [InlineData("name")]
- public void BindToMoniker_InvalidMonikerName_ThrowsCOMException(string monikerName)
- {
- Assert.Throws<COMException>(() => Marshal.BindToMoniker(monikerName));
- }
}
}
[Theory]
[InlineData(unchecked((int)0x80020006))]
[InlineData(unchecked((int)0x80020101))]
- [ActiveIssue(30866)]
public void GetExceptionForHR_EqualsErrorCode(int err)
{
+ ClearCurrentIErrorInfo();
Exception ex = Marshal.GetExceptionForHR(err);
Assert.Equal(err, ex.HResult);
}
public void GetExceptionForHR_ThrowExceptionForHR_ThrowsSameException()
{
const int ErrorCode = unchecked((int)0x80131D0B);
- COMException getHRException = Marshal.GetExceptionForHR(ErrorCode) as COMException;
+
+ ClearCurrentIErrorInfo();
+ var getHRException = (COMException)Marshal.GetExceptionForHR(ErrorCode);
Assert.Equal(ErrorCode, getHRException.HResult);
try
{
Assert.Null(Marshal.GetExceptionForHR(errorCode));
Assert.Null(Marshal.GetExceptionForHR(errorCode, IntPtr.Zero));
}
+
+ private static void ClearCurrentIErrorInfo()
+ {
+ // Ensure that if the thread's current IErrorInfo
+ // is set during a run that it is thrown away prior
+ // to interpreting the HRESULT.
+ Marshal.GetExceptionForHR(unchecked((int)0x80040001));
+ }
}
}