I am new to TypeMock and have been trying to figure this out. If someone could help me I would greatly appreciate it.
So I have a Method in the MasterOrderBPO class:
public PoeordersCollection GetOrders(Int32 inID)
{
IPredicateExpression Filter = new PredicateExpression();
Filter.Add(PoeordersFields.MasterOrderId == inID);
PoeordersCollection Orders = new PoeordersCollection();
Orders.GetMulti(Filter);
return Orders;
}
and I want to run a test on it and always get the count as 1 for Orders.Count
so here is the test:
public void ValidGetOrders()
{
bool hasErrors = true;
Mock orderMock = MockManager.MockAll(typeof(PoeordersCollection));
orderMock.ExpectGetAlways("Count", 1);
PoeordersCollection order = new PoeordersCollection();
MasterOrderBPO orderCol = MasterOrderBPO.getInstance();
PoeordersCollection Order = orderCol.GetOrders(1);
if (Order.Count > 0)
{
hasErrors = false;
}
Assert.IsTrue(hasErrors == false, "The Master Order: " + moValid.MasterOrderId + " - Does Not Exist");
}
however, when it hits GetMulti I get:
failed: System.NullReferenceException : Object reference not set to an instance of an object.
at SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore`1.Clear()
What am I doing wrong? Please help me.