public void UserAgentHeaderPresentAndContainsVersion()
        {
            var mock = new MockRepository(MockBehavior.Loose);
            var request = mock.Create<WebRequest>();
            var headers = new WebHeaderCollection();
            request.SetupProperty(c => c.Headers, headers);
            UserAgentAdapter adapter = new UserAgentAdapter(new Version(1, 0));
            adapter.AddUserAgentToRequest(request.Object);
            Assert.AreEqual(1, request.Object.Headers.Count);

            Assert.IsNotNull(request.Object.Headers[HttpRequestHeader.UserAgent]);
            Assert.AreEqual("Azure Media Services .NET SDK v1.0", request.Object.Headers[HttpRequestHeader.UserAgent]);
        }
        private Uri GetAccountApiEndpoint(OAuthDataServiceAdapter dataServiceAdapter, ServiceVersionAdapter versionAdapter, Uri apiServer, UserAgentAdapter userAgentAdapter, IWebRequestAdapter clientRequestIdAdapter)
        {
            MediaRetryPolicy retryPolicy = new MediaRetryPolicy(
                GetWebRequestTransientErrorDetectionStrategy(),
                RetryStrategyFactory.DefaultStrategy());

            Uri apiEndpoint = null;
            retryPolicy.ExecuteAction(
                    () =>
                    {
                        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiServer);
                        request.AllowAutoRedirect = false;
                        dataServiceAdapter.AddAccessTokenToRequest(request);
                        versionAdapter.AddVersionToRequest(request);
                        userAgentAdapter.AddUserAgentToRequest(request);
                        clientRequestIdAdapter.AddClientRequestId(request);

                        using (WebResponse response = request.GetResponse())
                        {
                            apiEndpoint = GetAccountApiEndpointFromResponse(response);
                        }
                    }
                );

            return apiEndpoint;
        }