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 FailIfContentTypeIsBatch()
 {
     var host = new DataServiceHostSimulator { RequestHttpMethod = "GET" };
     host.SetQueryStringItem("$callback", "foo");
     Action method = () => CallbackQueryOptionHandler.HandleCallbackQueryOption(new AstoriaRequestMessage(host), new ODataFormatWithParameters(ODataFormat.Batch));
     method.ShouldThrow<DataServiceException>().WithMessage(ds.Strings.CallbackQueryOptionHandler_UnsupportedContentType(ODataFormat.Batch));
 }
 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");
 }
        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);
        }
        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);
        }