chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Hi All,

I need to mock call of the load method in the following code:

XslCompiledTransform transform = new XslCompiledTransform();
transform.Load(new XmlTextReader(templateStream, XmlNodeType.Element, null));

Any sugesstions which method should i use?
asked by mohit.vashishtha (1.2k points)

3 Answers

0 votes
Hi,

What exactly are you trying to fake?
  • If you want to avoid the call to load from accessing resources (like load the XSL from file system) you can use:
Isolate.WhenCalled(() => transform.Load((XmlTextReader)null)).IgnoreCall();

If you want to fake the transform (replace the behavior of Transform for example):
Isolate.WhenCalled(() => transform.Transform((XmlReader)null, (XmlWriter)null))
    .DoInstead(context => ((XmlWriter)context.Parameters[1]).WriteElementString("elem","x","val"));


Regards,
Elisha
Typemock Support
answered by Elisha (12k points)
0 votes
Thanks for the prompt reply...

Actualy i was trying to avoid the call. Sugessted code works for me.

Thanks again
answered by mohit.vashishtha (1.2k points)
0 votes
Thanks! this topic helped me alot too!
answered by Portia Perez (140 points)
...