mocking a null return type

44 views
Skip to first unread message

John Whish

unread,
Feb 14, 2013, 7:55:44 AM2/14/13
to mxu...@googlegroups.com
Hi guys, I've just been trying to mock a call to ORM where I expect it to return null. 

function mockNull(){
  var Gateway = mock().getBasket().returns( JavaCast("null","") );
  var result = Gateway.getBasket();
  assertTrue( IsNull( Gateway.getBasket() ) );
}


This was causing the error:
variable [ARG] doesn't exist : framework\mightymock\MightyMock.cfc (232)
 
I thought about using a special '{null}' value as a return type so you could do something like:

function mockNull(){
  var Gateway = mock().getBasket().returns( '{null}' );
  var result = Gateway.getBasket();
  assertTrue( IsNull( Gateway.getBasket() ) );
}

I had a go at doing this, by trapping the '{null}' argument, but haven't got it to work properly.

  function returns(){
   var arg = '';
   _$setState('idle');
   if( arguments.size() ) arg = arguments[1];
   if ( !IsSimpleValue( arg ) || arg != '{null}' ){
      registry.updateRegistry(currentMethod['name'],currentMethod['missingMethodArguments'],'returns',arg);
   }
   return this;
  }

Any thoughts?

Thanks,

John

Marc Esher

unread,
Mar 5, 2013, 9:47:48 AM3/5/13
to mxu...@googlegroups.com
Hey John,

This got lost in the shuffle. Have you worked this out yet?

Marc


--
You received this message because you are subscribed to the Google Groups "mxunit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mxunit+un...@googlegroups.com.
To post to this group, send email to mxu...@googlegroups.com.
Visit this group at http://groups.google.com/group/mxunit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

John Whish

unread,
Mar 6, 2013, 8:11:26 AM3/6/13
to mxu...@googlegroups.com
Hi Marc,

No I didn't get it working with MightyMock. Instead I just wrote a fake object (is that a fixture?) which mocked out the methods and used that instead of MightyMock.

Cheers,

John

Marc Esher

unread,
Mar 7, 2013, 10:14:37 AM3/7/13
to mxu...@googlegroups.com
Thanks for the update, John.
Reply all
Reply to author
Forward
0 new messages