Hi Kieth,
First - welcome to Typemock!
Typemock works best where you need to fake classes. With value types (such as SqlString) that you're trying to fake, it gets tricky. The support for structs is partial, since there are no struct instances. You can, as the message say, use the APIs for faking an "instance" and methods only once.
This is one of those rare cases of Isolator, where you actually need to change your code for the test. The best way is to introduce a wrapper class, like SqlStringWrapper that wraps the SqlString you want to change behavior to, and pass it instead to UserDefinedFunctions.FormatString. With classes, and therefore real instances, Isolator has no problem discerning which instance is which, and the rest of your test will run as you've written it.
For example:
public class SqlStringWrapper
{
SqlString instance;
public SqlStringWrapper(SqlString newString)
{
instance = newString;
}
public bool IsNull
{
get { return instance.IsNull; }
}
}
And then, change the signature of FormatString() to accept the SqlStringWrapper instances.
I'll put the missing feature on our backlog, so we won't forget it.
Please let me know if this helped, and if you got your test working.
Gil Zilberfeld
Typemock support team.