How to test WCF UriTemplates?

How to write unit test for testing UriTemplates (e.g. [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 ClientService, I have [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 claims the url clients/uri_1shows exactly the GetCollection ClientService method.

+3
source share
1 answer

You can Unit Testmethods GetCollectionand GetCollectionsjust call them and check that the return is not zero.

, , Integration Test. -. Unit test, , Smoke test, ?

, . Unit Tests, , . , Integration Tests .

0

Source: https://habr.com/ru/post/1782466/


All Articles