public void IgnoresOtherStuffInHost()
        {
            var host = new DataServiceHostSimulator {
                RequestHttpMethod = "GET"
            };

            host.SetQueryStringItem("$callback", "foo");
            host.SetQueryStringItem("$format", "atom");
            var result = CallbackQueryOptionHandler.HandleCallbackQueryOption(new AstoriaRequestMessage(host), new ODataFormatWithParameters(ODataFormat.Json));

            result.Should().Be("foo");
        }
        public void FailIfContentTypeIsMetadata()
        {
            var host = new DataServiceHostSimulator {
                RequestHttpMethod = "GET"
            };

            host.SetQueryStringItem("$callback", "foo");
            Action method = () => CallbackQueryOptionHandler.HandleCallbackQueryOption(new AstoriaRequestMessage(host), new ODataFormatWithParameters(ODataFormat.Metadata));

            method.ShouldThrow <DataServiceException>().WithMessage(ds.Strings.CallbackQueryOptionHandler_UnsupportedContentType(ODataFormat.Metadata));
        }
        public void FailIfMethodIsNotGet()
        {
            var host = new DataServiceHostSimulator {
                RequestHttpMethod = "POST"
            };

            host.SetQueryStringItem("$callback", "foo");
            Action method = () => CallbackQueryOptionHandler.HandleCallbackQueryOption(new AstoriaRequestMessage(host), new ODataFormatWithParameters(ODataFormat.Json));

            method.ShouldThrow <DataServiceException>().WithMessage(ds.Strings.CallbackQueryOptionHandler_GetRequestsOnly);
        }
        public void CallbackQueryOptionShouldWorkIfRaw()
        {
            var host = new DataServiceHostSimulator {
                RequestHttpMethod = "GET"
            };

            host.SetQueryStringItem("$callback", "foo");
            var result = CallbackQueryOptionHandler.HandleCallbackQueryOption(new AstoriaRequestMessage(host), new ODataFormatWithParameters(ODataFormat.RawValue));

            result.Should().Be("foo");
        }
Пример #5
0
        public void GetDollarFormatQueryItemShouldGetValueFromHostGetQueryStringItemMethod()
        {
            const string queryKey   = "$format";
            const string queryValue = "custom";
            var          host       = new DataServiceHostSimulator {
            };

            host.SetQueryStringItem(queryKey, queryValue);
            var requestMessage = new AstoriaRequestMessage(host);

            requestMessage.GetQueryStringItem(queryKey).Should().Be(queryValue);
        }
Пример #6
0
        public void GetQueryStringItemShouldGetComponentFromHostGetQueryStringItemMethod()
        {
            const string queryKey   = "queryKey";
            const string queryValue = "queryValue";
            var          host       = new DataServiceHostSimulator {
                AbsoluteRequestUri = new Uri("http://www.service.com/there/is/not/even/a/query-string")
            };

            host.SetQueryStringItem(queryKey, queryValue);
            var requestMessage = new AstoriaRequestMessage(host);

            requestMessage.GetQueryStringItem(queryKey).Should().Be(queryValue);
        }