asp.net web api2 - WebApi Controller Unit Test not working for HttpResponseMessage -


i haven't written unit test in while, maybe im out of swing of things. im trying test httpresponsemessage controller in webapi. have no error, test completes green check find strange because when went debug double check assert realized wasn't ever hitting assert. here test.

[fact]     public void testdudemancontroller()     {         //arrange         dudemanmodel dmmrequest =  new dudemanmodel();         dudemanmodel dmmresponse = new dudemanmodel();         httpresponsemessage hrm = new httpresponsemessage();         dmmrequest.name = "test-duder";         dmmresponse.name = "hey " + dmmrequest.name + ", im dude man.";         var dudecontroller = new dudemancontroller();                 dudecontroller.request = new httprequestmessage();         dudecontroller.configuration = new httpconfiguration();                 //act         hrm = dudecontroller.dude(dmmrequest);          //assert         //assert.equal(4, 4);         assert.true(hrm.issuccessstatuscode);                } 

here controller

[httppost]     [route("dude")]     public httpresponsemessage dude([frombody]dudemanmodel name)     {         log.info("webapi post initiated::name is::" + name.name);          name.name = "hey " + name.name + ", im dude man.";         name.link = "dude.png";         log.infoformat("webapi post updated::name is::{0}::pic is::{1}", name.name, name.link);          return request.createresponse(httpstatuscode.ok, name);     } 

basically line 'dudecontroller.configuration = new httpconfiguration();' , that's it. test over. test marked passed.

this standard .net framework webapi , im using xunit testing. idea why test bows out line successful test, i'd appreciate help. im not finding on searches far.

*****disclaimer

just in case wondering, there's nothing weird test controller. code homage movie the big lebowski. , forever 'the dude'. reading code, little funny im seeing here.

so weird had project set release in visual studio, switched debug , works now, i'm getting assert. simple fix. i'm not sure behavior regarding why, if has add please let me know.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -