/// <summary>
        /// Process all properties (regular and navigation properties) while preserving their order in
        /// the payload.
        /// </summary>
        /// <param name="entry">The <see cref="ODataEntry"/> to process the properties for.</param>
        public static void ProcessPropertiesPreservingPayloadOrder(this ODataEntry entry, Action <ODataProperty> propertyAction, Action <ODataNavigationLink> navigationLinkAction)
        {
            ExceptionUtilities.CheckArgumentNotNull(entry, "entry");
            ExceptionUtilities.CheckArgumentNotNull(propertyAction, "propertyAction");
            ExceptionUtilities.CheckArgumentNotNull(navigationLinkAction, "navigationLinkAction");

            ODataEntryNavigationLinksObjectModelAnnotation navigationLinks = entry.NavigationLinks();

            if (navigationLinks == null)
            {
                navigationLinks = new ODataEntryNavigationLinksObjectModelAnnotation();
            }

            int navigationLinksProcessed = 0;

            // NOTE we iterate over all the properties here just to get the count; since this is test code only we don't care
            int navigationLinkCount = navigationLinks == null ? 0 : navigationLinks.Count;
            int totalPropertyCount  = entry.Properties.Count() + navigationLinkCount;

            // NOTE: we are preserving the same order of items as in the payload, i.e., if regular
            //       properties and navigation properties are interleaved we preserve their relative order.
            using (IEnumerator <ODataProperty> propertyEnumerator = entry.Properties.GetEnumerator())
            {
                ODataNavigationLink navigationLink;
                for (int i = 0; i < totalPropertyCount; ++i)
                {
                    if (navigationLinks != null && navigationLinks.TryGetNavigationLinkAt(i, out navigationLink))
                    {
                        navigationLinkAction(navigationLink);
                        navigationLinksProcessed++;
                    }
                    else
                    {
                        bool hasMore = propertyEnumerator.MoveNext();
                        Debug.Assert(hasMore, "More properties were expected.");
                        propertyAction(propertyEnumerator.Current);
                    }
                }
            }

            Debug.Assert(navigationLinksProcessed == navigationLinkCount, "All navigation links should have been processed.");
        }