public void GetQueryStringItemAsksHost()
 {
     var host = new DataServiceHost2Simulator();
     host.SetQueryStringItem("some-key", "test-value");
     DataServiceOperationContext context = new DataServiceOperationContext(host);
     context.GetQueryStringValue("some-key").Should().Be("test-value");
 }
        public string ResolveType(string entitySetName, DataServiceOperationContext operationContext)
        {
            // This code is required by a test verifying that we can call GetQueryStringItem in an stream provider method.
            var forceErrorValue = operationContext.GetQueryStringValue("Query-String-Header-Force-Error");
            if (forceErrorValue == "yes")
            {
                throw new DataServiceException(418, "User code threw a Query-String-Header-Force-Error exception.");
            }

            this.ThrowIfDisposed();
            CallOrderLog += "-ResolveType";
            if (DataServiceStreamProvider.ResolveTypeOverride != null)
            {
                return DataServiceStreamProvider.ResolveTypeOverride(entitySetName, operationContext);
            }

            return operationContext.RequestHeaders["CustomRequestHeader_ItemType"];
        }
 public void GetQueryStringItemEmptyParameterReturnsNullIndependentOfHost()
 {
     var host = new StupidHostSimulator();
     DataServiceOperationContext context = new DataServiceOperationContext(host);
     context.GetQueryStringValue("").Should().Be(null);
 }
 public void GetMissingQueryStringItemReturnsNullIfHostReturnsNull()
 {
     var host = new DataServiceHost2Simulator();
     DataServiceOperationContext context = new DataServiceOperationContext(host);
     context.GetQueryStringValue("some-key").Should().Be(null);
 }