c# - Should I test if my controller's Action method are calling the repository methods and generating the right view? -
i'm new testing , started testing mvc application.
currently i'm testing if controller's action method calling right repository methods in turn reads or writes data database.
what i'm testing if return type of action method view, partialview or redirecttoroute, etc.
i've got comments saying testing if controller's action method calling right function in repository doesn't make sense. true?
what should include in unit test mvc application, uses repository pattern well.
it make sense check if action call correct method on repository you'll need mock avoid access database. unit tests should isolated external components.
although it's not ideal, replace "real" database lightweight in memory sqlite avoid mocking database access in tests.
i use moq mocking framework plenty of mature mocking framework .net.
take account testing if method called checks behavior instead of status. make test more fragil becomes dependent on internal implementation, depending scenario perfeclty valid.
Comments
Post a Comment