Ejemplo n.º 1
0
        public void GetWorksForValuesWithWhitespace()
        {
            var collection = new NameValueCollection();

            collection.Add("somekey", "the value\t with WHITESPACE");
            HttpContextServiceHost.GetQueryStringItem("somekey", collection).Should().Be("the value\t with WHITESPACE");
        }
Ejemplo n.º 2
0
        public void GetDoesNotCareAboutSpecialDollarCharacter()
        {
            var collection = new NameValueCollection();

            collection.Add("$isreserved$butwedontcarehere", "thevalue");
            HttpContextServiceHost.GetQueryStringItem("$isreserved$butwedontcarehere", collection).Should().Be("thevalue");
        }
Ejemplo n.º 3
0
        public void GetWillTrimExcessWhiteSpaceOffKey()
        {
            var collection = new NameValueCollection();

            collection.Add("\tsomekey  \n\r", "thevalue");
            HttpContextServiceHost.GetQueryStringItem("somekey", collection).Should().Be("thevalue");
        }
Ejemplo n.º 4
0
        public void GetPresentKeyShouldReturnItsValue()
        {
            var collection = new NameValueCollection();

            collection.Add("somekey", "thevalue");
            HttpContextServiceHost.GetQueryStringItem("somekey", collection).Should().Be("thevalue");
        }
Ejemplo n.º 5
0
        public void VerifyDoesNotAllowDollarLinks()
        {
            var collection = new NameValueCollection();

            collection.Add("$ref", "value");
            Action action = () => HttpContextServiceHost.VerifyQueryParameters(collection);

            action.ShouldThrow <DataServiceException>().WithMessage("The query parameter '$ref' begins with a system-reserved '$' character but is not recognized.");
        }
Ejemplo n.º 6
0
        public void VerifyDoesNotAllowRepeatFormat()
        {
            var collection = new NameValueCollection();

            collection.Add("$format", "json");
            collection.Add("$format", "atom");
            Action action = () => HttpContextServiceHost.VerifyQueryParameters(collection);

            action.ShouldThrow <DataServiceException>().WithMessage("Query parameter '$format' is specified, but it should be specified exactly once.");
        }
Ejemplo n.º 7
0
        public void VerifyDoesNotAllowControlInfo()
        {
            // $controlinfo was briefly used for controlling how much metadata a client wanted
            // in JSON-Light payloads. It was removed and replaced with a parameter in the media type.
            var collection = new NameValueCollection();

            collection.Add("$controlinfo", "value");
            Action action = () => HttpContextServiceHost.VerifyQueryParameters(collection);

            action.ShouldThrow <DataServiceException>().WithMessage("The query parameter '$controlinfo' begins with a system-reserved '$' character but is not recognized.");
        }
Ejemplo n.º 8
0
        public void VerifyAllowsWellKnownDollarQueryOptions()
        {
            var collection = new NameValueCollection();

            collection.Add("$select", "value");
            collection.Add("$filter", "value");
            collection.Add("$top", "value");
            collection.Add("$skip", "value");
            collection.Add("$expand", "value");
            collection.Add("$orderby", "value");
            collection.Add("$count", "value");
            collection.Add("$format", "value");
            collection.Add("$callback", "value");
            Action action = () => HttpContextServiceHost.VerifyQueryParameters(collection);

            action.ShouldNotThrow();
        }
Ejemplo n.º 9
0
 public void GetMissingKeyShouldReturnNull()
 {
     HttpContextServiceHost.GetQueryStringItem("missing_item", new NameValueCollection()).Should().Be(null);
 }