Ejemplo n.º 1
0
        private void VerifyLoadProperty(object entity, string propertyName, WebDataCtxWrapper Context)
        {
            Uri entityUri = null;

            if (Context.TryGetUri(entity, out entityUri))
            {
                Uri  navigationPropertyURI = new Uri(String.Format("{0}/{1}", entityUri.OriginalString, propertyName));;
                Type navPropType           = entity.GetType().GetProperty(propertyName).PropertyType;
                if (navPropType.IsGenericType)
                {
                    navPropType = navPropType.GetGenericArguments()[0];
                }
                WebDataCtxWrapper baselineCOntext = new WebDataCtxWrapper(Context.BaseUri);
                baselineCOntext.Credentials = CredentialCache.DefaultCredentials;
                QueryOperationResponse qoResponse = baselineCOntext.ExecuteOfT(navPropType, navigationPropertyURI) as QueryOperationResponse;
                IEnumerator            enumerator = qoResponse.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    object baselineEntity   = enumerator.Current;
                    Uri    navPropEntityURI = null;
                    if (baselineCOntext.TryGetUri(baselineEntity, out navPropEntityURI))
                    {
                        AstoriaTestLog.IsNotNull(Context.TryGetEntityOfT(navPropType, navPropEntityURI), "Could not find entity in Navigation property ");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void InsertReferenceNavProperty()
        {
            ForEachResourceType(
                (resourceType, resourceContainer, workspace) =>
            {
                CreateContext(resourceType, workspace);
#if !ClientSKUFramework
                object entity = ExecuteURI(resourceType, String.Format("/{0}", resourceContainer.Name));
                Uri entityUri = null;


                IEdmEntityType entityType = DataServiceMetadata.GetEntityType(entity);
                if (entityType == null)
                {
                    return;
                }
                CurrentContext.TryGetUri(entity, out entityUri);
                foreach (string refNavProperty in entityType.ReferenceNavigationProperties())
                {
                    ResourceType navResType = workspace.ServiceContainer.ResourceTypes.FirstOrDefault(rt => rt.Name == refNavProperty);
                    if (navResType != null)
                    {
                        object navEntity      = navResType.CreateInstance(false);
                        string navPropertyURI = String.Format("{0}/{1}", entityUri.Segments[entityUri.Segments.Length - 1], refNavProperty);
                        CurrentContext.AddObject(navPropertyURI, navEntity);
                        CurrentContext.EnsureInsert(navEntity, navResType);
                    }
                }
                ExecuteAndValidate(() => CurrentContext.SaveChanges(SaveChangeOption));
                if (ContinueTest)
                {
                    if (ChainedFunction != null)
                    {
                        ChainedFunction();
                    }
                }
#endif
            }, true);
        }