Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:39:08+00:00 2026-05-22T23:39:08+00:00

How do I write a unit test to test the UriTemplates (such as [WebGet(Uritemlpate={clientId}/returns)]

  • 0

How do I write a unit test to test the UriTemplates (such as [WebGet(Uritemlpate="{clientId}/returns")] in my WCF services?

For example, in Global.asax I have:

private void RegisterRoutes()
{
     RouteTable.Routes.Add(new ServiceRoute("clients", 
                new WebServiceHostFactory(), typeof(ClientService)));
}

In the ClientService I have a [WebGet(Uritemlpate="uri_1")]:

    [ServiceContract]
    public class ClientService 
    {
        [WebGet(UriTemplate = "uri_1")]
        public string GetCollection()
        {
            return "Method 1";
        }

        [WebGet(UriTemplate = "uri_2")]
        public string GetCollections()
        {
            return "Method 2";
        }
    }

I want to have a test that Asserts the url clients/uri_1 hits exactly method GetCollection of ClientService.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:39:09+00:00Added an answer on May 22, 2026 at 11:39 pm

    You can Unit Test the methods GetCollection and GetCollections by just calling them and checking the return is not null.

    What you are actually want to do is an Integration Test. This requires the external dependency of a web server. Check out the difference between the types here
    What is Unit test, Integration Test, Smoke test, Regression Test?

    It is worth while having both. We run Unit Tests when we commit code automatically, it is them auto-deployed to a integrations. domain, the Integration Tests are then run against this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all I have this situation , I need to write unit test cases
I am wondering should I write unit test for everything. There are some classes
How does one write a unit test that fails only if a function doesn't
I need to write a unit test for a method that will print a
How do I write a unit test for a method that use an external
I want to write a unit test for a Django manage.py command that does
How can I write a unit test to test the ActualWidth property in a
I am trying to write a unit test for an action method which calls
I'm trying to write a unit test for a module that will give me
I'm trying to write a unit test that will loop through all action methods

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.