Mock Webservices

4 posts, 0 answers
  1. joao
    joao avatar
    1 posts
    Member since:
    Aug 2010

    Posted 10 Sep 2010 Link to this post

    Hi, i bought justmock, and reading JustMock  documents  i dont find how to mock web 
    services, i need create a mock web services(Request,response etc..) anybody have a example?
  2. Ricky
    Ricky avatar
    467 posts

    Posted 15 Sep 2010 Link to this post

    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
  3. DevCraft R3 2016 release webinar banner
  4. Yachana
    Yachana avatar
    2 posts
    Member since:
    Jul 2014

    Posted 07 Jul 2014 in reply to Ricky Link to this post


    can u please provide some thing relevant to web services (web methods unit testing with out any valid url or invoking the web service).

  5. Kaloyan
    Kaloyan avatar
    871 posts

    Posted 10 Jul 2014 Link to this post

    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:
    // 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.


    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.

Back to Top