Пример #1
0
        public void CanGetAcceptLanguageViaProperty()
        {
            var options = new RequestOptions();

            options.AddHeader("Accept-Language", "tchoupitoulas");
            Assert.Equal("tchoupitoulas", options.AcceptLanguage);
        }
Пример #2
0
        public void CanAddHeaders()
        {
            var options = new RequestOptions();

            options.AddHeader("Custom-Header", "tchoupitoulas");
            Assert.True(options.Headers.ContainsKey("Custom-Header"));
            Assert.Equal("tchoupitoulas", options.Headers["Custom-Header"]);
        }
        public void WillIncludeCustomHeaders()
        {
            var options = new RequestOptions();

            options.AddHeader("Accept-Language", "en-US");
            var matcher = MockClient.HeaderMatcher(new Dictionary <string, object> {
                { "Accept-Language", "en-US" },
            });
            var client = MockClient.Build(matcher, NotFoundResponse());

            Assert.Throws <Recurly.Errors.NotFound>(() => client.GetResource("douglas/", "param1", new DateTime(2020, 01, 01), options));
        }
        public void WillAddQueryStringParameters()
        {
            var options = new RequestOptions();

            options.AddHeader("Accept-Language", "en-US");
            var date          = new DateTime(2020, 01, 01);
            var paramsMatcher = MockClient.QueryParameterMatcher(new Dictionary <string, object> {
                { "param_1", "param1" },
                { "param_2", Recurly.Utils.ISO8601(date) },
            });

            var        client   = MockClient.Build(paramsMatcher, SuccessResponse(System.Net.HttpStatusCode.OK));
            MyResource resource = client.GetResource("benjamin", "param1", date, options);

            Assert.Equal("benjamin", resource.MyString);
        }
Пример #5
0
        public void CanNotAddIdempotencyKey()
        {
            var options = new RequestOptions();

            Assert.Throws <ArgumentException>(() => options.AddHeader("Idempotency-Key", "tchoupitoulas"));
        }
Пример #6
0
        public void CanNotAddAuthorization()
        {
            var options = new RequestOptions();

            Assert.Throws <ArgumentException>(() => options.AddHeader("Authorization", "tchoupitoulas"));
        }
Пример #7
0
        public void CanNotAddContentType()
        {
            var options = new RequestOptions();

            Assert.Throws <ArgumentException>(() => options.AddHeader("Content-Type", "tchoupitoulas"));
        }
Пример #8
0
        public void CanNotAddUserAgent()
        {
            var options = new RequestOptions();

            Assert.Throws <ArgumentException>(() => options.AddHeader("User-Agent", "tchoupitoulas"));
        }