I inherited a small console application that makes calls to the SOAP web service. This is a tragic mess of nested trap attempts that break exceptions in different ways, and I would like to wrap some test coverage around how it behaves when a SoapException is thrown.
Question: How can I make fun of a class, such as SoapException, using Moq, when I canโt mock the interface and I canโt make the properties or methods โvirtualโ?
A bit more explanation:
To test this error handling, I need to manage the property Actorof the SoapException object as well as the property Detailto check the error handling.
Excerpt from my unit test code:
[TestMethod]
public void MyTestMethod()
{
Mock<SoapException> soapMock = new Mock<SoapException>(MockBehavior.Strict);
soapMock.SetupGet<string>(ex => ex.Actor).Returns("Test Actor");
, Actor "Virtual", Moq SetupGet(...) :
System.NotSupportedException: ( VB) : ex = > ex.Actor
, . , .NET framework, Actor .
SoapException ?
, SoapException XML , XML. , , , .