Exemple #1
0
        public void CustomNamedRequestIdHeadTest()
        {
            const string validSubscription = "1234-5678-9012-3456";
            const string expectedRequestId = "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0";

            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(validSubscription, Guid.NewGuid().ToString())))
            {
                AzureOperationResponse <bool, HeaderCustomNamedRequestIdHeadHeaders> response = client.Header.CustomNamedRequestIdHeadWithHttpMessagesAsync(expectedRequestId).Result;
                Assert.True(response.Body);
                Assert.Equal("123", response.RequestId);
            }
        }
Exemple #2
0
        public void XmsRequestClientIdInClientTest()
        {
            var validSubscription = "1234-5678-9012-3456";

            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(validSubscription, Guid.NewGuid().ToString()))
            {
                SubscriptionId = validSubscription
            })
            {
                client.GenerateClientRequestId = false;
                client.XMsClientRequestId.Get();
            }
        }
Exemple #3
0
        public void ClientRequestIdInExceptionTest()
        {
            var validSubscription = "1234-5678-9012-3456";

            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(validSubscription, Guid.NewGuid().ToString()))
            {
                SubscriptionId = validSubscription
            })
            {
                Dictionary <string, List <string> > customHeaders = new Dictionary <string, List <string> >();
                var exception = Assert.Throws <CloudException>(() => client.XMsClientRequestId.Get());
                Assert.Equal("123", exception.RequestId);
            }
        }
Exemple #4
0
        public void CustomNamedRequestIdTest()
        {
            SwaggerSpecRunner.RunTests(
                SwaggerPath("azure-special-properties.json"), ExpectedPath("AzureSpecials"), generator: "Azure.CSharp");

            const string validSubscription = "1234-5678-9012-3456";
            const string expectedRequestId = "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0";

            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(validSubscription, Guid.NewGuid().ToString())))
            {
                IAzureOperationResponse response = client.Header.CustomNamedRequestIdWithHttpMessagesAsync(expectedRequestId).Result;

                Assert.Equal("123", response.RequestId);
            }
        }
Exemple #5
0
        public void CustomNamedRequestIdParameterGroupingTest()
        {
            const string validSubscription = "1234-5678-9012-3456";
            const string expectedRequestId = "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0";

            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(validSubscription, Guid.NewGuid().ToString())))
            {
                var group = new HeaderCustomNamedRequestIdParamGroupingParameters()
                {
                    FooClientRequestId = expectedRequestId
                };
                IAzureOperationResponse response = client.Header.CustomNamedRequestIdParamGroupingWithHttpMessagesAsync(group).Result;

                Assert.Equal("123", response.RequestId);
            }
        }
Exemple #6
0
        public void AzureSpecialParametersTests()
        {
            var validSubscription = "1234-5678-9012-3456";
            var validApiVersion   = "2.0";
            var unencodedPath     = "path1/path2/path3";
            var unencodedQuery    = "value1&q2=value2&q3=value3";

            SwaggerSpecRunner.RunTests(
                SwaggerPath("azure-special-properties.json"), ExpectedPath("AzureSpecials"), generator: "Azure.CSharp");
            using (
                var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                          new TokenCredentials(Guid.NewGuid().ToString()))
            {
                SubscriptionId = validSubscription
            })
            {
                client.SubscriptionInCredentials.PostMethodGlobalNotProvidedValid();
                client.SubscriptionInCredentials.PostMethodGlobalValid();
                client.SubscriptionInCredentials.PostPathGlobalValid();
                client.SubscriptionInCredentials.PostSwaggerGlobalValid();
                client.SubscriptionInMethod.PostMethodLocalValid(validSubscription);
                client.SubscriptionInMethod.PostPathLocalValid(validSubscription);
                client.SubscriptionInMethod.PostSwaggerLocalValid(validSubscription);
                Assert.Throws <ValidationException>(() => client.SubscriptionInMethod.PostMethodLocalNull(null));

                client.ApiVersionDefault.GetMethodGlobalNotProvidedValid();
                client.ApiVersionDefault.GetMethodGlobalValid();
                client.ApiVersionDefault.GetPathGlobalValid();
                client.ApiVersionDefault.GetSwaggerGlobalValid();
                client.ApiVersionLocal.GetMethodLocalValid(validApiVersion);
                client.ApiVersionLocal.GetMethodLocalNull(null);
                client.ApiVersionLocal.GetPathLocalValid(validApiVersion);
                client.ApiVersionLocal.GetSwaggerLocalValid(validApiVersion);

                client.SkipUrlEncoding.GetMethodPathValid(unencodedPath);
                client.SkipUrlEncoding.GetPathPathValid(unencodedPath);
                client.SkipUrlEncoding.GetSwaggerPathValid(unencodedPath);
                client.SkipUrlEncoding.GetMethodQueryValid(unencodedQuery);
                client.SkipUrlEncoding.GetPathQueryValid(unencodedQuery);
                client.SkipUrlEncoding.GetSwaggerQueryValid(unencodedQuery);
                client.SkipUrlEncoding.GetMethodQueryNull();
                client.SkipUrlEncoding.GetMethodQueryNull(null);
            }
        }
Exemple #7
0
        public void AzureODataTests()
        {
            var validSubscription = "1234-5678-9012-3456";

            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(Guid.NewGuid().ToString()))
            {
                SubscriptionId = validSubscription
            })
            {
                var filter = new ODataQuery <OdataFilter>(f => f.Id > 5 && f.Name == "foo")
                {
                    Top     = 10,
                    OrderBy = "id"
                };
                Assert.Equal("$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10", filter.ToString());
                client.Odata.GetWithFilter(filter);
            }
        }
Exemple #8
0
        public void AzureODataTests()
        {
            var validSubscription = "1234-5678-9012-3456";

            SwaggerSpecRunner.RunTests(
                SwaggerPath("azure-special-properties.json"), ExpectedPath("AzureSpecials"), generator: "Azure.CSharp");
            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(Guid.NewGuid().ToString()))
            {
                SubscriptionId = validSubscription
            })
            {
                var filter = new ODataQuery <OdataFilter>(f => f.Id > 5 && f.Name == "foo")
                {
                    Top     = 10,
                    OrderBy = "id"
                };
                Assert.Equal("$filter=id gt 5 and name eq 'foo'&$orderby=id&$top=10", filter.ToString());
                client.Odata.GetWithFilter(filter);
            }
        }
Exemple #9
0
        public void XmsRequestClientIdTest()
        {
            var validSubscription = "1234-5678-9012-3456";
            var validClientId     = "9C4D50EE-2D56-4CD3-8152-34347DC9F2B0";

            using (var client = new AutoRestAzureSpecialParametersTestClient(Fixture.Uri,
                                                                             new TokenCredentials(validSubscription, Guid.NewGuid().ToString()))
            {
                SubscriptionId = validSubscription
            })
            {
                Dictionary <string, List <string> > customHeaders = new Dictionary <string, List <string> >();
                customHeaders["x-ms-client-request-id"] = new List <string> {
                    validClientId
                };
                var result1 = client.XMsClientRequestId.GetWithHttpMessagesAsync(customHeaders)
                              .ConfigureAwait(true).GetAwaiter().GetResult();
                Assert.Equal("123", result1.RequestId);

                var result2 = client.XMsClientRequestId.ParamGetWithHttpMessagesAsync(validClientId)
                              .ConfigureAwait(false).GetAwaiter().GetResult();
                Assert.Equal("123", result2.RequestId);
            }
        }