3 Answers, 1 is accepted
0
Hi joao,
Unfortunately, there is no specific example of mocking web services in the current documentation. However, by mocking web services you will be mocking client proxy which is similar to mocking any other .net classes.
Additionally, I attached a solution containing some getting started examples that shows mocking of web services using JustMock. There are basic as well as an example that illustrates mocking of an async call.
Hope that helps,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Yachana
Top achievements
Rank 1
answered on 07 Jul 2014, 10:55 AM
Hi
can u please provide some thing relevant to web services (web methods unit testing with out any valid url or invoking the web service).
Thanks
Yachana
can u please provide some thing relevant to web services (web methods unit testing with out any valid url or invoking the web service).
Thanks
Yachana
0
Hi Yachana,
Basically, you should be able to mock almost everything with the commercial version of JustMock. However, could you provide some sample code that needs to be tested in order to see where your concerns come from?
Further, here is a simple example of mocking the System.Net.WebResponse and WebRequest classes:
I hope this helps. Looking forward to your reply.
Regards,
Kaloyan
Telerik
Basically, you should be able to mock almost everything with the commercial version of JustMock. However, could you provide some sample code that needs to be tested in order to see where your concerns come from?
Further, here is a simple example of mocking the System.Net.WebResponse and WebRequest classes:
// Arrange
var expectedRequest =
new
Uri(
"http://myUrl/Request"
);
var expectedResponse =
new
Uri(
"http://myUrl/Response"
);
var response = Mock.Create<WebResponse>();
var request = Mock.Create<WebRequest>();
Mock.Arrange(() => request.RequestUri).Returns(expectedRequest);
Mock.Arrange(() => response.ResponseUri).Returns(expectedResponse);
// Act
var actualRequest = request.RequestUri;
var actualResponse = response.ResponseUri;
// Assert
Assert.AreEqual(expectedRequest, actualRequest);
Assert.AreEqual(expectedResponse, actualResponse);
I hope this helps. Looking forward to your reply.
Regards,
Kaloyan
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.