コード例 #1
0
        public void WebExceptionShouldNotBeSurfacedWhenGetResponseThrowsOnBatch()
        {
            IODataRequestMessage requestMessage = new ODataTestMessage();

            var context = new DataServiceContextWithCustomTransportLayer(ODataProtocolVersion.V4, () => requestMessage, () => { throw new WebException("web exception on getting response"); });
            Action test = () =>  context.ExecuteBatch(context.CreateQuery<NorthwindModel.Products>("Products"));

            test.ShouldThrow<WebException>().WithMessage("web exception on getting response");
        }
コード例 #2
0
        private static Action GetQueryWithInjectedObjectDisposedOnGetStream(bool useExecuteBatch)
        {
            IODataRequestMessage requestMessage = new ODataTestMessage();
            var responseMessage = CreateResponseMessageWithGetStreamThrowingObjectDisposeException();

            var context = new DataServiceContextWithCustomTransportLayer(ODataProtocolVersion.V4, requestMessage, responseMessage);
            if (useExecuteBatch)
            {
                return () => context.ExecuteBatch(context.CreateQuery<NorthwindModel.Products>("Products"));
            }
            else
            {
                return () => context.CreateQuery<NorthwindModel.Products>("Products").ToList();
            }
        }