Hi,
I'm struggling to basically fake a return from a property that is contained in a public class, with an internal private class.
Whatever I try I can't get it to work. Here's the class:
namespace SixPack.Data
{
/// <summary>
/// This class is used to wrap and execute stored procedures.
/// </summary>
public class StoredProcedure : IDisposable
{
private class ConnectionInfo
{
private readonly string connectionString;
/// <summary>
/// Gets the connection string.
/// </summary>
/// <value>The connection string.</value>
public string ConnectionString
{
get
{
return connectionString;
}
}
I'm trying to fake the ConnectionString property, as I don't want the test to rely on config files etc. I'd have thought this would be easy enough to do, so this is what I've tried :
var myType = Type.GetType("SixPack.Data.StoredProcedure+ConnectionInfo, SixPack, Version=1.1.1.0, Culture=neutral, PublicKeyToken=d2a7cc6ee67de205");
Isolate.NonPublic.Property.WhenGetCalled(myType,"ConnectionString").WillReturn("astring");
And here's the error I get :
*** Failures ***
Execute
TypeMock.TypeMockException:
*** No get property with name ConnectionString in type SixPack.Data.StoredProcedure+ConnectionInfo exists.
at ht.b(Type A_0, String A_1, ir A_2, Boolean A_3)
at g4.b(Type A_0, String A_1)
at xxxx(Boolean deleteOldMessages, Int32 daysOld, Int32 incompleteTimeout) in xxxx.cs:line 53
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Boolean A_5, Object[] A_6)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType, Object p1, Object p2, Object p3)
at xxxx(Boolean deleteOldMessages, Int32 daysOld, Int32 incompleteTimeout) in xxxx.cs:line 36
### Step FetchUtmMessagesToProcess_Call_ReturnProc: failed ###
Any ideas as I'm stumped now? It's version 6.0.4 - they're quite behind I'm afraid.
Thanks in advance,
Tony