< Summary

Class:Microsoft.Azure.CognitiveServices.Search.NewsSearch.NewsSearchClient
Assembly:Microsoft.Azure.CognitiveServices.Search.BingNewsSearch
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Search.BingNewsSearch\src\Generated\NewsSearch\NewsSearchClient.cs
Covered lines:46
Uncovered lines:21
Coverable lines:67
Total lines:221
Line coverage:68.6% (46 of 67)
Covered branches:3
Total branches:12
Branch coverage:25% (3 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_BaseUri()-100%100%
get_SerializationSettings()-100%100%
get_DeserializationSettings()-100%100%
get_Endpoint()-100%100%
get_Credentials()-100%100%
get_News()-100%100%
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-0%100%
.ctor(...)-85.71%75%
.ctor(...)-0%0%
.ctor(...)-0%0%
Initialize()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Search.BingNewsSearch\src\Generated\NewsSearch\NewsSearchClient.cs

#LineLine coverage
 1// <auto-generated>
 2// Code generated by Microsoft (R) AutoRest Code Generator.
 3// Changes may cause incorrect behavior and will be lost if the code is
 4// regenerated.
 5// </auto-generated>
 6
 7namespace Microsoft.Azure.CognitiveServices.Search.NewsSearch
 8{
 9    using Microsoft.Rest;
 10    using Microsoft.Rest.Serialization;
 11    using Models;
 12    using Newtonsoft.Json;
 13    using System.Collections;
 14    using System.Collections.Generic;
 15    using System.Net;
 16    using System.Net.Http;
 17
 18    /// <summary>
 19    /// The News Search API lets you send a search query to Bing and get back a
 20    /// list of news that are relevant to the search query. This section
 21    /// provides technical details about the query parameters and headers that
 22    /// you use to request news and the JSON response objects that contain
 23    /// them. For examples that show how to make requests, see [Searching the
 24    /// web for
 25    /// news](https://docs.microsoft.com/en-us/azure/cognitive-services/bing-news-search/search-the-web).
 26    /// </summary>
 27    public partial class NewsSearchClient : ServiceClient<NewsSearchClient>, INewsSearchClient
 28    {
 29        /// <summary>
 30        /// The base URI of the service.
 31        /// </summary>
 1232        internal string BaseUri {get; set;}
 33
 34        /// <summary>
 35        /// Gets or sets json serialization settings.
 36        /// </summary>
 1237        public JsonSerializerSettings SerializationSettings { get; private set; }
 38
 39        /// <summary>
 40        /// Gets or sets json deserialization settings.
 41        /// </summary>
 1842        public JsonSerializerSettings DeserializationSettings { get; private set; }
 43
 44        /// <summary>
 45        /// Supported Cognitive Services endpoints (protocol and hostname, for example:
 46        /// "https://westus.api.cognitive.microsoft.com",
 47        /// "https://api.cognitive.microsoft.com").
 48        /// </summary>
 1849        public string Endpoint { get; set; }
 50
 51        /// <summary>
 52        /// Subscription credentials which uniquely identify client subscription.
 53        /// </summary>
 3054        public ServiceClientCredentials Credentials { get; private set; }
 55
 56        /// <summary>
 57        /// Gets the INewsOperations.
 58        /// </summary>
 1259        public virtual INewsOperations News { get; private set; }
 60
 61        /// <summary>
 62        /// Initializes a new instance of the NewsSearchClient class.
 63        /// </summary>
 64        /// <param name='httpClient'>
 65        /// HttpClient to be used
 66        /// </param>
 67        /// <param name='disposeHttpClient'>
 68        /// True: will dispose the provided httpClient on calling NewsSearchClient.Dispose(). False: will not dispose pr
 069        protected NewsSearchClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
 70        {
 071            Initialize();
 072        }
 73
 74        /// <summary>
 75        /// Initializes a new instance of the NewsSearchClient class.
 76        /// </summary>
 77        /// <param name='handlers'>
 78        /// Optional. The delegating handlers to add to the http client pipeline.
 79        /// </param>
 680        protected NewsSearchClient(params DelegatingHandler[] handlers) : base(handlers)
 81        {
 682            Initialize();
 683        }
 84
 85        /// <summary>
 86        /// Initializes a new instance of the NewsSearchClient class.
 87        /// </summary>
 88        /// <param name='rootHandler'>
 89        /// Optional. The http client handler used to handle http transport.
 90        /// </param>
 91        /// <param name='handlers'>
 92        /// Optional. The delegating handlers to add to the http client pipeline.
 93        /// </param>
 094        protected NewsSearchClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandle
 95        {
 096            Initialize();
 097        }
 98
 99        /// <summary>
 100        /// Initializes a new instance of the NewsSearchClient class.
 101        /// </summary>
 102        /// <param name='credentials'>
 103        /// Required. Subscription credentials which uniquely identify client subscription.
 104        /// </param>
 105        /// <param name='handlers'>
 106        /// Optional. The delegating handlers to add to the http client pipeline.
 107        /// </param>
 108        /// <exception cref="System.ArgumentNullException">
 109        /// Thrown when a required parameter is null
 110        /// </exception>
 6111        public NewsSearchClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handle
 112        {
 6113            if (credentials == null)
 114            {
 0115                throw new System.ArgumentNullException("credentials");
 116            }
 6117            Credentials = credentials;
 6118            if (Credentials != null)
 119            {
 6120                Credentials.InitializeServiceClient(this);
 121            }
 6122        }
 123
 124        /// <summary>
 125        /// Initializes a new instance of the NewsSearchClient class.
 126        /// </summary>
 127        /// <param name='credentials'>
 128        /// Required. Subscription credentials which uniquely identify client subscription.
 129        /// </param>
 130        /// <param name='httpClient'>
 131        /// HttpClient to be used
 132        /// </param>
 133        /// <param name='disposeHttpClient'>
 134        /// True: will dispose the provided httpClient on calling NewsSearchClient.Dispose(). False: will not dispose pr
 135        /// <exception cref="System.ArgumentNullException">
 136        /// Thrown when a required parameter is null
 137        /// </exception>
 0138        public NewsSearchClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : t
 139        {
 0140            if (credentials == null)
 141            {
 0142                throw new System.ArgumentNullException("credentials");
 143            }
 0144            Credentials = credentials;
 0145            if (Credentials != null)
 146            {
 0147                Credentials.InitializeServiceClient(this);
 148            }
 0149        }
 150
 151        /// <summary>
 152        /// Initializes a new instance of the NewsSearchClient class.
 153        /// </summary>
 154        /// <param name='credentials'>
 155        /// Required. Subscription credentials which uniquely identify client subscription.
 156        /// </param>
 157        /// <param name='rootHandler'>
 158        /// Optional. The http client handler used to handle http transport.
 159        /// </param>
 160        /// <param name='handlers'>
 161        /// Optional. The delegating handlers to add to the http client pipeline.
 162        /// </param>
 163        /// <exception cref="System.ArgumentNullException">
 164        /// Thrown when a required parameter is null
 165        /// </exception>
 0166        public NewsSearchClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHa
 167        {
 0168            if (credentials == null)
 169            {
 0170                throw new System.ArgumentNullException("credentials");
 171            }
 0172            Credentials = credentials;
 0173            if (Credentials != null)
 174            {
 0175                Credentials.InitializeServiceClient(this);
 176            }
 0177        }
 178
 179        /// <summary>
 180        /// An optional partial-method to perform custom initialization.
 181        ///</summary>
 182        partial void CustomInitialize();
 183        /// <summary>
 184        /// Initializes client properties.
 185        /// </summary>
 186        private void Initialize()
 187        {
 6188            News = new NewsOperations(this);
 6189            BaseUri = "{Endpoint}/bing/v7.0";
 6190            Endpoint = "https://api.cognitive.microsoft.com";
 6191            SerializationSettings = new JsonSerializerSettings
 6192            {
 6193                Formatting = Newtonsoft.Json.Formatting.Indented,
 6194                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 6195                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 6196                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 6197                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 6198                ContractResolver = new ReadOnlyJsonContractResolver(),
 6199                Converters = new  List<JsonConverter>
 6200                    {
 6201                        new Iso8601TimeSpanConverter()
 6202                    }
 6203            };
 6204            DeserializationSettings = new JsonSerializerSettings
 6205            {
 6206                DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
 6207                DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
 6208                NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
 6209                ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
 6210                ContractResolver = new ReadOnlyJsonContractResolver(),
 6211                Converters = new List<JsonConverter>
 6212                    {
 6213                        new Iso8601TimeSpanConverter()
 6214                    }
 6215            };
 6216            SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<ResponseBase>("_type"));
 6217            DeserializationSettings.Converters.Add(new  PolymorphicDeserializeJsonConverter<ResponseBase>("_type"));
 218            CustomInitialize();
 6219        }
 220    }
 221}