Esempio n. 1
0
        private static void QueryEntitySet(DataServiceContextWrapper <DefaultContainer> contextWrapper)
        {
            contextWrapper.Configurations.ResponsePipeline
            .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryId_Reading)
            .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingStart)
            .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingEnd)
            .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryAction_Reading)
            .OnNestedResourceInfoEnded(PipelineEventsTestsHelper.ModifyAssociationLinkUrl_ReadingNavigationLink)
            .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomer_Materialized);

            var entryResultsLinq = contextWrapper.CreateQuery <Customer>("Customer").ToArray();

            foreach (var customer in entryResultsLinq)
            {
                PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
            }

            var entryResultsExecute = contextWrapper.Execute <Customer>(new Uri("Customer", UriKind.Relative));

            foreach (Customer customer in entryResultsExecute)
            {
                PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
            }

            var customerQuery = contextWrapper.CreateQuery <Customer>("Customer");
            DataServiceCollection <Customer> entryResultsCollection = new DataServiceCollection <Customer>(customerQuery);

            foreach (Customer customer in entryResultsCollection)
            {
                PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
            }
        }
Esempio n. 2
0
        private static void QueryEntitySetExecuteAsync(DataServiceContextWrapper <DefaultContainer> contextWrapper)
        {
            contextWrapper.Configurations.ResponsePipeline
            .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryId_Reading)
            .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingStart)
            .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingEnd)
            .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryAction_Reading)
            .OnNestedResourceInfoEnded(PipelineEventsTestsHelper.ModifyAssociationLinkUrl_ReadingNavigationLink)
            .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomer_Materialized);

            IEnumerable <Customer> customers = null;
            IAsyncResult           r         = contextWrapper.BeginExecute <Customer>(
                new Uri("Customer", UriKind.Relative),
                result => { customers = contextWrapper.EndExecute <Customer>(result); },
                null);

            while (!r.IsCompleted)
            {
                Thread.Sleep(1000);
            }

            foreach (Customer customer in customers)
            {
                PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
            }
        }
Esempio n. 3
0
        public void QueryEntitySet()
        {
            this.RunOnAtomAndJsonFormats(
                this.CreateContext,
                (contextWrapper) =>
            {
                contextWrapper.Configurations.ResponsePipeline
                .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryId_Reading)
                .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingStart)
                .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingEnd)
                .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryAction_Reading)
                .OnNavigationLinkEnded(PipelineEventsTestsHelper.ModifyAssociationLinkUrl_ReadingNavigationLink)
                .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomer_Materialized);

                // cover this for Json
                if (contextWrapper.Format.ODataFormat == ODataFormat.Atom)
                {
                    contextWrapper.Configurations.ResponsePipeline.OnNavigationLinkStarted(PipelineEventsTestsHelper.ModifyLinkName_ReadingNavigationLink);
                }

                var entryResultsLinq = contextWrapper.CreateQuery <Customer>("Customer").ToArray();
                foreach (var customer in entryResultsLinq)
                {
                    PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
                }

                var entryResultsExecute = contextWrapper.Execute <Customer>(new Uri("Customer", UriKind.Relative));
                foreach (Customer customer in entryResultsExecute)
                {
                    PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
                }

                var customerQuery = contextWrapper.CreateQuery <Customer>("Customer");
                DataServiceCollection <Customer> entryResultsCollection = new DataServiceCollection <Customer>(customerQuery);
                foreach (Customer customer in entryResultsCollection)
                {
                    PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
                }
            });
        }
        public void QueryEntitySetExecuteAsync()
        {
            this.RunOnAtomAndJsonFormats(
                this.CreateContext,
                (contextWrapper) =>
            {
                contextWrapper.Configurations.ResponsePipeline
                .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryId_Reading)
                .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingStart)
                .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingEnd)
                .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryAction_Reading)
                .OnNavigationLinkEnded(PipelineEventsTestsHelper.ModifyAssociationLinkUrl_ReadingNavigationLink)
                .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomer_Materialized);

                // cover this for Json
                if (contextWrapper.Format.ODataFormat == ODataFormat.Atom)
                {
                    contextWrapper.Configurations.ResponsePipeline.OnNavigationLinkStarted(PipelineEventsTestsHelper.ModifyLinkName_ReadingNavigationLink);
                }

                IEnumerable <Customer> customers = null;
                IAsyncResult r = contextWrapper.BeginExecute <Customer>(
                    new Uri("Customer", UriKind.Relative),
                    result =>
                {
                    customers = contextWrapper.EndExecute <Customer>(result);
                },
                    null);

                while (!r.IsCompleted)
                {
                    Thread.Sleep(1000);
                }

                foreach (Customer customer in customers)
                {
                    PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
                }
            });
        }
        private static void QueryEntitySetLinqAsync(DataServiceContextWrapper <DefaultContainer> contextWrapper)
        {
            contextWrapper.Configurations.ResponsePipeline
            .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryId_Reading)
            .OnEntryStarted(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingStart)
            .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryEditLink_ReadingEnd)
            .OnEntryEnded(PipelineEventsTestsHelper.ModifyEntryAction_Reading)
            .OnNavigationLinkEnded(PipelineEventsTestsHelper.ModifyAssociationLinkUrl_ReadingNavigationLink)
            .OnEntityMaterialized(PipelineEventsTestsHelper.ModifyPropertyValueCustomer_Materialized);

            // cover this for Json
            if (contextWrapper.Format.ODataFormat == ODataFormat.Atom)
            {
                contextWrapper.Configurations.ResponsePipeline.OnNavigationLinkStarted(
                    PipelineEventsTestsHelper.ModifyLinkName_ReadingNavigationLink);
            }

            var query = contextWrapper.CreateQuery <Customer>("Customer");

            var customers = Enumerable.Empty <Customer>();
            var r         = query.BeginExecute(
                result =>
            {
                customers = query.EndExecute(result);
            }, null);

            while (!r.IsCompleted)
            {
                Thread.Sleep(1000);
            }

            foreach (Customer customer in customers)
            {
                PipelineEventsTestsHelper.VerifyModfiedCustomerEntry(contextWrapper, customer);
            }
        }