Use structureMap.autoMocking with objectFactory.BuildUp

320 Views Asked by At

My class is like:

public class BillingAccountBLService : IBillingAccountBLService
{
    [SetterProperty]
    public IContractService ContractService { get; set; }

    public BillingAccountBLService()
    {
        ObjectFactory.BuildUp(this);
    }
}

In my test:

[Test]
public void ContractDoesNotExist()
{
   var mocks = new RhinoAutoMocker<BillingAccountBLService>();
   var service = mocks.ClassUnderTest;
   ...

on this row exception thrown

StructureMap.StructureMapConfigurationException : No default Instance is registered and cannot be automatically determined for type..." (type of first injected service)

How should I fix this?

0

There are 0 best solutions below