A three part series. Part 1: The set-up. Setting up an example to show what we are trying to stub. Part 2: Creating a REST service stub. Part 3: Using the service stub from a test. In this post I will provide the "set-up" for the later posts – basically this post will explain what I am trying to stub by giving some URI, Model and XML examples. Firstly, here is the simple object model that the RESTful service returns as XML. Essentially we have an order which contains some order lines. Each order includes a URI to the child resource – i.e. to an array of order lines, and each order line has a URI back to the parent resource – i.e. to the parent order. I'm going to create a "Order Query System" – the system under test – that uses the RESTful service to retrieve data and I will need to stub it to create some robust and consistently repeatable integration tests. public class Orders { public Order[] ArrayOfOrders { get; set; } } public class Order { public int Id { get; set; } public DateTime OrderDate { get; set; } public string OrderLinesRef { get; set; } } public class OrderLines { public OrderLine[] ArrayOfOrderLines { get; set; } } public class OrderLine { public int Id { get; set; } public string OrderRef { get; set; } } To get an order with ID=2, we hit the RESTful URI http://localhost:7000/OrderingSystem/Order/2.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
.NET,Test Driven Development,WCF,REST,Stubbing RESTful Services,TDD
.NET,Test Driven Development,WCF,REST,Stubbing RESTful Services,TDD
No comments:
Post a Comment