Esempio 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.EnqueueConditional(() => op.IsComplete);
            this.EnqueueCallback(() =>
            {
                // Expect a 'Not Found'
                Assert.IsInstanceOfType(error, typeof(DomainOperationException));
                Assert.IsInstanceOfType(error.InnerException, typeof(CommunicationException));

                this.CreateDomainContext(WebDomainClientTests.GenerateUriBase(2072)); // --> 2084, one over the max length
                ExceptionHelper.ExpectException <InvalidOperationException>(() =>
                                                                            this.CityDomainContext.Echo(""));
            });
            this.EnqueueTestComplete();
        }
Esempio n. 2
0
        public void Query_ShouldSupportLongQueries()
        {
            LoadOperation <Zip> op               = null;
            Exception           error            = null;
            const int           zipToFind        = 98053;
            const int           QUERY_ITERATIONS = 50;

            this.EnqueueCallback(() =>
            {
                this.CreateDomainContext();

                // Generate a really long query
                // The load will result in a query where just the query part has length > 3000
                var query = CityDomainContext.GetZipsQuery();

                // Create a query with QUERY_ITERATIONS where statements checking a range of QUERY_ITERATIONS each
                // this should in the end if simplified result in Code = zipToFind (zipToFind - 1 < Code  <= zipToFind)
                for (int i = 0; i < QUERY_ITERATIONS; ++i)
                {
                    int min = zipToFind + i - QUERY_ITERATIONS;
                    int max = zipToFind + i;
                    query   = query.Where(c => min < c.Code && c.Code <= max);
                }

                op = this.CityDomainContext.Load(query,
                                                 (lo) => WebDomainClientTests.HandleError(lo, ref error),
                                                 null);
            });
            this.EnqueueConditional(() => op.IsComplete);
#if SILVERLIGHT
            this.EnqueueCallback(() =>
            {
                // The query should match a single zip
                //new Zip() { Code=98053, FourDigit=8625, CityName="Redmond", CountyName="King", StateName="WA" },
                Assert.IsFalse(op.HasError, string.Format("The query returned the following error: {0}", op.Error));
                Assert.AreEqual(1, op.Entities.Count(), "A single entity was expected");

                var zip = op.Entities.First();
                Assert.AreEqual(zipToFind, zip.Code, "A single entity was expected");
                Assert.AreEqual(8625, zip.FourDigit);
                Assert.AreEqual("Redmond", zip.CityName);
            });
#endif
            this.EnqueueTestComplete();
        }