c# - Consuming an ASMX and mocking the methods -
c# - Consuming an ASMX and mocking the methods -
i have consume number of asmx webservices in poject method calls making hard unit test rest of code.
when i've consumed wcf service in past generates interface client allows me mock service calls in unit tests.
is same thing possible asmx webservices?
my solution
add web reference in visual studio right-clicking onservice references > add together service reference > advanced > add together web reference
. open reference.cs
file generated right-click on class name of service , take refactor > extract > extract interface
. give interface representing service methods. create new partial class service , create inherit new interface, making sure namespace , name of class match of service in reference.cs
now you've got interface, you'll able mock service in unit tests.
i hope helps other people , if theres easier method please allow me know.
c# wcf unit-testing mocking asmx
Comments
Post a Comment