Overview:
The problem I'm trying to solve is - I have some canceled orders in my database that I need to call a government WebService to disable the fiscal numbers associated with these orders.
The specific problem is:
I'm creating a class to create the XML request that should be sent to the government. It has a method that received an order as argument and should return the XML that will be sent to the government.
The process of creating the XML has three steps:
- Create the basic XML with some fixed info and some info from the order
- Sign this XML
- Envelop this XML in a SOAP request
The method I want to test is this:
public class RequestBuilder
{
public RequestBuilder(DisablerParameters disablerParameters, XmlSigner xmlSigner, XmlEnveloper xmlEnveloper)
{
this.disablerParameters = disablerParameters;
this.xmlSigner = xmlSigner;
this.xmlEnveloper = xmlEnveloper
}
public string BuildXml(Order order)
{
string xml = "<inutNFe>";
int year = order.getYear();
int orderId = order.getId();
xml += this.disablerParameters.fillParameters(year, orderId);
xml += "<inutNFe>";
string signed_xml = this.xmlSigner.sign(xml);
string enveloped_xml = this.xmlEnveloper.envelop(signed_xml);
return enveloped_xml;
}
}
The DisablerParameters
class has the fixed values and a method that received the order dependent data and return a XML with the fixed and order dependent values.
My problem is:
The way I think it would be correct to test this method would be a supply an order and I check if the returned XML is valid. But in order for this to work I would have to provide valid implementations of the dependencies and this would be more like an integration test than a unit test. If I supply mocks and test if the mock methods were called I think I would be testing the implementation not the behavior.