Exemplo n.º 1
0
        public void Invoke_MaximumUriLengthExceeded()
        {
            OperationBase op    = null;
            Exception     error = null;

            this.EnqueueCallback(() =>
            {
                this.CreateDomainContext(WebDomainClientTests.GenerateUriBase(2071)); // --> 2083, the max length
                op = this.CityDomainContext.Echo(
                    "",
                    (io) => WebDomainClientTests.HandleError(io, ref error),
                    null);
            });
            this.EnqueueCompletion(() => op);
            this.EnqueueCallback(() =>
            {
                Assert.IsInstanceOfType(error, typeof(DomainOperationException));
                Assert.IsInstanceOfType(error.InnerException, typeof(CommunicationException));
                var webException = error.InnerException.InnerException as System.Net.WebException;
                StringAssert.Contains(webException?.Message, "404");

                this.CreateDomainContext(WebDomainClientTests.GenerateUriBase(2072)); // --> 2084, one over the max length
                ExceptionHelper.ExpectException <InvalidOperationException>(() =>
                                                                            this.CityDomainContext.Echo(""));
            });
            this.EnqueueTestComplete();
        }
Exemplo n.º 2
0
        public void Query_MaximumUriLengthExceeded()
        {
            OperationBase op    = null;
            Exception     error = null;

            this.EnqueueCallback(() =>
            {
                this.CreateDomainContext(WebDomainClientTests.GenerateUriBase(2066)); // --> 2083, the max length
                op = this.CityDomainContext.Load(
                    this.CityDomainContext.GetCitiesQuery(),
                    (lo) => WebDomainClientTests.HandleError(lo, ref error),
                    null);
            });
            this.EnqueueCompletion(() => op);
            this.EnqueueCallback(() =>
            {
                // Expect a 'Not Found'
                Assert.IsInstanceOfType(error, typeof(DomainOperationException));
                Assert.IsInstanceOfType(error.InnerException, typeof(CommunicationException));
                StringAssert.Contains(error.InnerException.InnerException?.Message, "404");

                this.CreateDomainContext(WebDomainClientTests.GenerateUriBase(2067)); // --> 2084, one over the max length
                ExceptionHelper.ExpectException <InvalidOperationException>(() =>
                                                                            this.CityDomainContext.Load(this.CityDomainContext.GetCitiesQuery()));
            });
            this.EnqueueTestComplete();
        }