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
I recently upgraded from 4.5.2 to 6.0 and now have a several tests failing with a typemock exception.

The application I am developing tests for is based on the CSLA framework by Rockford Lotkha.

I am including the exception info, my unit test code, the class being tested, and the base class from CSLA where I can trace the issue to, prior to typemock throwing a fit:

This is the last method I can trace to:
protected P GetProperty<P>(PropertyInfo<P> propertyInfo)
      return GetProperty<P>(propertyInfo, Security.NoAccessBehavior.SuppressException);

////////// ERROR ////////////
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in TypeMock.dll

Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
set_Item(Int32 index, T value)
s.a(IList`1 A_0, MethodBase A_1, IEnumerable`1 A_2)
s.a(Object A_0, MethodBase A_1, Object[] A_2)
s.a(MethodBase A_0, Object A_1, Type A_2, Object[] A_3, Object A_4)
s.a(MethodBase A_0, Object A_1, Object[] A_2, Object A_3)
ic.a(String A_0, Object[] A_1, Object A_2, Object A_3, String A_4, Type A_5)
df.a(String A_0, Object A_1, MethodBase A_2, Object[] A_3, Object A_4, String A_5, ic A_6)
df.a(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
GetProperty[P](PropertyInfo`1 propertyInfo) in C:Documents and SettingsFVanOmmeMy DocumentsMy ProjectsCSLAcslacs-3.7.1-090806cslacsCslaReadOnlyBase.cs: line 824
Wlgore.LQS.Library.FormatFileInfo.get_FormatFile() in C:ProjectsLQSWLGore.LQS.LibraryReadOnlyClassesFormatFileInfo.cs: line 27
LQSTesting.PrintItemsUnitTest.PrintItemsControllerSetFilter() in C:ProjectsLQSLQSTestingPrintItemsUnitTest.cs: line 108
TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
LQSTesting.PrintItemsUnitTest.PrintItemsControllerSetFilter() in C:ProjectsLQSLQSTestingPrintItemsUnitTest.cs: line 0

////////// TEST ////////////
[code] [TestMethod, Isolated]
public void PrintItemsControllerSetFilter()
// Arrange
var fakeDal = Isolate.Fake.Instance<Wlgore>();

Isolate.WhenCalled(() => fakeDal.GetItemNumbersAndFormatsFromQualification(FormatType.Box)).DoInstead(context => { return new ItemNumberFormatStub().GetDataReaderStub(); });
Isolate.WhenCalled(() => fakeDal.GetFormats(FormatType.Box)).DoInstead(context => { return new FormatFileStub().GetDataReaderStub(); });
Isolate.WhenCalled(() => fakeDal.GetItemNumbersFromQualification(FormatType.Box, @"\SomeServerSomeDirectoryBOX_FORMAT_1.FMT")).WithExactArguments().DoInstead(context => { return new SingleItemNumbersStub().GetDataReaderStub(); });
Isolate.WhenCalled(() => fakeDal.GetItemNumbersFromQualification(FormatType.Box, @"\SomeServerSomeDirectoryBOX_FORMAT_2.FMT")).WithExactArguments().DoInstead(context => { return new ItemNumbersStub().GetDataReaderStub(); });

// Act
var testObj = Wlgore.LQS.Library.PrintItemsController.GetController();
testObj.FormatType = FormatType.Box;

var newFormatFileFilter = testObj.FormatsFilterList[0].FormatFile;
testObj.FormatFileFilter = newFormatFileFilter;

// Assert
Assert.IsTrue(testObj.FormatType == FormatType.Box);
Assert.IsTrue(testObj.FormatFileFilter == newFormatFileFilter);
Assert.IsTrue(testObj.PrintItems.Count == 0);
Assert.IsTrue(testObj.FormatsFilterList.Count == 2);
Assert.IsTrue(testObj.ItemNumbersFilterList.Count == 0);
Assert.IsTrue(testObj.FilteredItemNumbers.Count == 1);

////////// CLASS CODE ////////////
public class FormatFileInfo : Core.ReadOnlyBase<FormatFileInfo>
#region Factory Methods
internal static FormatFileInfo GetChild(IDataReader dr)
var child = new FormatFileInfo();
return child;

#region Properties
public static PropertyInfo<string> FormatFileProperty = RegisterProperty<string>(c => c.FormatFile);
public string FormatFile
get { return GetProperty<string>(FormatFileProperty); } // STEPPING IN TO THE GETPROPERTY METHOD CAUSES THE ERROR

public static PropertyInfo<FormatType> FormatTypeProperty = RegisterProperty<FormatType>(c => c.FormatType);
public FormatType FormatType
get { return GetProperty(FormatTypeProperty); }

#region Data Access
private void Fetch(IDataReader dr)
if (dr != null)
LoadProperty<string>(FormatFileProperty, dr.GetString(dr.GetOrdinal("FORMAT")).Trim());

string ft = dr.GetString(dr.GetOrdinal("FORMAT_TYPE")).Trim();
LoadProperty<FormatType>(FormatTypeProperty, ((FormatType)Enum.Parse(typeof(FormatType), ft, true)));

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.Serialization;
using Csla.Core;
using Csla.Properties;
using Csla.Core.FieldManager;
using Csla.Core.LoadManager;
using Csla.Reflection;
using Csla.Server;
using Csla.Security;

namespace Csla
/// <summary>
/// This is a base class from which readonly business classes
/// can be derived.
/// </summary>
/// <remarks>
/// This base class only supports data retrieve, not updating or
/// deleting. Any business classes derived from this base class
/// should only implement readonly properties.
/// &lt
asked by fvanomme (1.6k points)

1 Answer

0 votes

Lets take it offline, I'll send you a mail from our support and we'll continue from there.
answered by ohad (35.5k points)