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 on service 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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -