Mocking transfer mean

Forgive me if this makes no sense; I'm trying to get my head around
unit testing / mocking.

I'm trying to write a test for my model's saveBox function. It takes
a transfer bean of type box.box - checks if it is valid then saves it
(using boxService) or throws an error.

So how would I go about mocking a transfer bean? Or am I getting the
wrong end of the stick?

Cheers!

My test so far:

<cfcomponent extends="coldbox.system.testing.BaseModelTest"
appMapping="/ppp">

  <cffunction name="setUp" returntype="void" output="false">
    <cfscript>

    super.setup();

    boxModel = getMockBox().createMock(className="model.BoxModel");

    </cfscript>
  </cffunction>

  <cffunction name="testSave" returntype="void" output="false">
    <cfscript>

    box = // mock transfer object here and set some properties on it?

    boxModel.saveBox(box );

    </cfscript>
  </cffunction>

</cfcomponent>

you can do two things

  1. Mock a transfer object
    box = getMockBox().createEmptyMock(“transfer.com.TransferObject”)
    // check the paths, I am not sure

  2. Create a stub object
    box = getMockBox().createStub();

Then mock properties on it.

That’s it!

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Thanks very much for the reply. I'll give that a go!