For my .NET C# application, I'm using a third-party e-faxing software named efaxdeveloper.com
I needed to mock efaxdeveloper.com's software OutboundResponse object.
Please keep in mind that since it's 3rd party, I obviously can Not modify the 3rd-party dlls.
In the eFaxDeveloper.dll, the following is the code for the OutboundResponse class:
using System.Runtime.InteropServices;
namespace J2.eFaxDeveloper.Outbound
{
//
// Summary:
// oubound response
[ClassInterface(ClassInterfaceType.AutoDual)]
[System.Runtime.Serialization.DataContractAttribute(Namespace = "")]
public class OutboundResponse
{
public OutboundResponse();
//
// Summary:
// Unique client specified transmission identifier
public string TransmissionID { get; }
//
// Summary:
// eFax Developer™ transmission identifier
public string DOCID { get; }
//
// Summary:
// J2.eFaxDeveloper.Outbound.StatusCode
public StatusCode StatusCode { get; }
//
// Summary:
// Status description
public string StatusDescription { get; }
//
// Summary:
// J2.eFaxDeveloper.Outbound.ErrorLevel
public ErrorLevel ErrorLevel { get; }
//
// Summary:
// Error message
public string ErrorMessage { get; }
}
}
Since it only has getters, I tried the following snippet of code:
OutboundResponse outboundResponseInQuestion = Substitute.For<OutboundResponse>();
outboundResponseInQuestion.TransmissionID.Returns("someTransmissionID");
Unfortunately, outboundResponseInQuestion.TransmissionID throws
'outboundResponseInQuestion.TransmissionID' threw an exception of type 'System.NullReferenceException'
I can Not create an Interface for the OutboundResponse class so could someone please tell me how I can mock said object using NSubstitute and make it return the proper values?