c# - Autofixture - GuardClauseException -


i encountered strange exception while working nunit , autofixture unit testing.

i have different classes objects input , doing httprequest depending on objects ( i'm formatting objects json , make requests )

in unit test this:

ifixture fixture = new fixture().customize(new automoqcustomization()); var assertion = new guardclauseassertion(fixture); 

then classes this:

assertion.verify(typeof(myclass)); 

every class until passed test 1 not. test throws exception

message: ploeh.autofixture.idioms.guardclauseexception : guard clause test performed on method may contain deferred iterator block, test failed. see inner exception more details. however, because of deferred nature of iterator block, test failure may false positive. perhaps have guard clause in place, in conjunction 'yield' keyword (if you're using c#); if case, guard clause dormant, , first triggered when client starts looping on iterator. doesn't adhere fail fast principle, should addressed. 

and inner exception:

----> ploeh.autofixture.idioms.guardclauseexception : attempt made assign value null parameter "status" of method "changestatus", , no guard clause prevented this. missing guard clause? method signature: system.string changestatus(interfaces.iproject, status) parameter type: status, , version=1.0.0.0 culture=neutral, publickeytoken=bd4b9bc26bc147ff declaring type: releaserepository,  version=1.0.0.0, culture=neutral, publickeytoken=bd4b9bc26bc147ff reflected type: releaserepository version=1.0.0.0, culture=neutral, publickeytoken=bd4b9bc26bc147ff   ----> system.invalidoperationexception : passed project has no valid name. 

in last method of class looks this:

if(string.isnullorempty(myobject.name))      throw new invalidoperationexception("..."); 

the method mentionted in inner exception this: (status enum, got error other objects wasnt enums)

public string changestatus(iobject1, iobject2, status status) { // here if clauses check if null or not given return client.post(url, status); } 

i'm wondering because same if clause in other classes same type of object , pass.

(it's same test:)

assertion.verify(typeof(myobject).getmethods()); 

i have no idea reason.

my class passed test now.

sorry didn't / couldn't gave mcv couldn't / can't reproduce problem @ all.

i deleted if clauses , added , @ point added null check enum status in changestatus()

public string changestatus(iobject1, iobject2, status status) if(status == null)    throw new exception(); 

this solved error. thought tried same before asking question.

thanks every , time.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -