c# - Should I unit test a simple update app service? -


should unit testing app service simple 1 shown below?

public void update(useraccountviewmodel viewmodel)     {         var instance = mapper.map<useraccountviewmodel, useraccount>(viewmodel);         _useraccountservice.updateinstance(instance);     } 

as can see takes in view model, uses automapper map domain model , calls domain service method update object. if should unit testing i'm struggling see unit test! perhaps answers own question argue there's nothing test other automapper's work believe should not unit testing anyway else's work right?

edit: replies. i've gone tests updateinstance method called once:

[testmethod] public void givenviewmodelwheneditingauserthentheupdateinstancedomainservicemethodiscalledonce() {     // arrange     _useraccounts.clear();     var viewmodel = new mock<useraccountviewmodel>();      // act     _useraccountappservice.update(viewmodel.object);      // assert     _useraccountservice.verify(e => e.updateinstance(it.isany<useraccount>()), times.once()); } 

"what unit test" subjective question. answers range "nothing; it's waste of time" "always 100% code coverage." favor pragmatic unit testing. in case, update method little that, imo, it's not worth unit testing. you'd testing automapper, should tested creators.

unit testing real user account service's updateinstance method valuable, though.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -