However, the test raises an Unhandled Exception and I have got this message :
Test method SerialPortProviderTests.OpenTest_ThrowException_CloseCalled threw exception:
System.Reflection.TargetInvocationException: An exception was thrown by the target of a call. ---> System.Exception: An exception of type 'System.Exception' was thrown.
I tried to make a function
serialPortC.Open()
throw an exception in that way :Shim shimserialPortCOpen = Shim.Replace(() => serialPortC.Open()).With(delegate (SerialPort @this) { throw new Exception(); });
to check after if
Close
function is called or Not.And my source code is :
And my test Code is :
However, the test raises an Unhandled Exception and I have got this message :