Esempio n. 1
0
        public void IdentityPathTest()
        {
            SimpleIdentity id         = new SimpleIdentity();
            IdentityPath   pathSimple = new IdentityPath(id);

            Assert.AreEqual(IdentityPath.ROOT, pathSimple.Parent);
            Assert.AreEqual(IdentityPath.ROOT, pathSimple.GetPathTo(-1));
            Assert.AreEqual(id, pathSimple.Child);
            Assert.AreEqual(1, pathSimple.Length);
            Assert.AreEqual(0, pathSimple.Depth);
            AssertEx.ThrowsException <IndexOutOfRangeException>(() => pathSimple.GetPathTo(-2));
            AssertEx.ThrowsException <IndexOutOfRangeException>(() => pathSimple.GetPathTo(1));

            IdentityPath pathRoot = new IdentityPath(new Identity[0]);

            Assert.AreEqual(IdentityPath.ROOT, pathRoot);
            Assert.AreEqual(0, pathRoot.Length);
            Assert.AreEqual(-1, pathRoot.Depth);
            AssertEx.ThrowsException <IndexOutOfRangeException>(() => pathRoot.Child);
            AssertEx.ThrowsException <IndexOutOfRangeException>(() => pathRoot.Parent);

            const int count = 5;

            List <Identity>        listId1  = new List <Identity>();
            List <Identity>        listId2  = new List <Identity>();
            HashSet <IdentityPath> setPaths = new HashSet <IdentityPath>();

            IdentityPath last = IdentityPath.ROOT;

            for (int i = 0; i < count; i++)
            {
                listId1.Add(new NumericIdentity(i));
                listId2.Add(new NumericIdentity(i));

                IdentityPath path = new IdentityPath(listId1);
                Assert.AreEqual(path, new IdentityPath(listId1));
                Assert.AreNotEqual(path, new IdentityPath(listId2));
                Assert.AreEqual(last, path.Parent);
                Assert.AreSame(listId1[i], path.Child);
                Assert.AreEqual(path, new IdentityPath(path.Parent, path.Child));
                Assert.AreEqual(i, path.Depth);
                Assert.AreEqual(listId1.Count, path.Length);
                Assert.AreSame(path.Child, path.GetIdentity(path.Depth));
                Assert.AreEqual(path.Parent, path.GetPathTo(path.Depth - 1));
                Assert.AreEqual("/" + listId1.ToString("/"), path.ToString());
                for (int j = 0; j < i; j++)
                {
                    Assert.IsTrue(setPaths.Contains(path.GetPathTo(j)));
                }
                setPaths.Add(path);
                last = path;
            }
        }
        public List <ActionObjectPath> GetRequest(IIdProvider idProvider)
        {
            IdentityPath = idProvider.GetActionId();
            QueryIdPath  = idProvider.GetActionId();

            List <ActionObjectPath> actions      = new List <ActionObjectPath>();
            ActionObjectPath        spoOperation = new ActionObjectPath()
            {
                Action = new QueryAction()
                {
                    Id           = QueryIdPath,
                    ObjectPathId = IdentityPath.ToString(),
                    SelectQuery  = new SelectQuery()
                    {
                        SelectAllProperties = false,
                        Properties          = new List <Property>()
                        {
                            new Property()
                            {
                                Name = "PollingInterval"
                            },
                            new Property()
                            {
                                Name = "IsComplete"
                            },
                        }
                    }
                }
            };

            ActionObjectPath identity = new ActionObjectPath()
            {
                ObjectPath = new Identity()
                {
                    Id   = IdentityPath,
                    Name = ObjectIdentity.Replace("\n", "&#xA;")
                }
            };

            actions.Add(spoOperation);
            actions.Add(identity);
            return(actions);
        }
Esempio n. 3
0
        public List <ActionObjectPath> GetRequest(IIdProvider idProvider)
        {
            IdentityPath = idProvider.GetActionId();
            QueryIdPath  = idProvider.GetActionId();
            int getSitePropertiesByUrl = idProvider.GetActionId();

            #region XML Payload generated

            /*
             * <Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName=".NET Library"
             *  xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
             *  <Actions>
             *      <ObjectPath Id="2" ObjectPathId="1" />
             *      <ObjectPath Id="4" ObjectPathId="3" />
             *      <Query Id="5" ObjectPathId="3">
             *          <Query SelectAllProperties="true">
             *                  <Properties />
             *          </Query>
             *      </Query>
             *  </Actions>
             *  <ObjectPaths>
             *      <Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" />
             *      <Method Id="3" ParentId="1" Name="GetSiteByUrl">
             *          <Parameters>
             *              <Parameter Type="String">https://bertonline.sharepoint.com/sites/prov-1</Parameter>
             *          </Parameters>
             *      </Method>
             *  </ObjectPaths>
             * </Request>
             */
            #endregion

            List <ActionObjectPath> actions = new List <ActionObjectPath>();

            ActionObjectPath spoOperation = new ActionObjectPath()
            {
                Action = new BaseAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = IdentityPath.ToString()
                },
            };

            ActionObjectPath spoOperation2 = new ActionObjectPath()
            {
                Action = new BaseAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = getSitePropertiesByUrl.ToString()
                },
            };

            ActionObjectPath spoOperation3 = new ActionObjectPath()
            {
                Action = new QueryAction()
                {
                    Id           = QueryIdPath,
                    ObjectPathId = getSitePropertiesByUrl.ToString(),
                    SelectQuery  = new SelectQuery()
                    {
                        SelectAllProperties = true
                    }
                },
            };

            ActionObjectPath createSiteAction = new ActionObjectPath()
            {
                ObjectPath = new ObjectPathMethod()
                {
                    Id         = getSitePropertiesByUrl,
                    ParentId   = IdentityPath,
                    Name       = "GetSiteByUrl",
                    Parameters = new MethodParameter()
                    {
                        Properties = new List <Parameter>()
                        {
                            new Parameter()
                            {
                                Type  = "String",
                                Value = SiteUrl.AbsoluteUri
                            }
                        }
                    }
                }
            };

            ActionObjectPath spoGetSitePropertiesByUrlCollection = new ActionObjectPath()
            {
                ObjectPath = new ConstructorPath
                {
                    Id     = IdentityPath,
                    TypeId = PnPAdminConstants.CsomTenantObject
                }
            };

            actions.Add(spoOperation);
            actions.Add(spoOperation2);
            actions.Add(spoOperation3);
            actions.Add(createSiteAction);
            actions.Add(spoGetSitePropertiesByUrlCollection);

            return(actions);
        }
        public List <ActionObjectPath> GetRequest(IIdProvider idProvider)
        {
            IdentityPath = idProvider.GetActionId();
            QueryIdPath  = idProvider.GetActionId();
            int updateId = idProvider.GetActionId();

            #region XML Payload generated

            /*
             * <Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="pnp core sdk"
             *  xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
             *  <Actions>
             *      <SetProperty Id="4" ObjectPathId="1" Name="DisableFlows">
             *          <Parameter Type="Enum">2</Parameter>
             *      </SetProperty>
             *      <SetProperty Id="5" ObjectPathId="1" Name="Title">
             *          <Parameter Type="String">New title 1</Parameter>
             *      </SetProperty>
             *      <Query Id="2" ObjectPathId="3">
             *          <Query SelectAllProperties="false">
             *              <Properties>
             *                  <Property Name="PollingInterval" ScalarProperty="true" />
             *                  <Property Name="IsComplete" ScalarProperty="true" />
             *              </Properties>
             *          </Query>
             *      </Query>
             *      <ObjectPath Id="6" ObjectPathId="3" />
             *      <ObjectIdentityQuery Id="7" ObjectPathId="1" />
             *  </Actions>
             *  <ObjectPaths>
             *      <Method Id="3" ParentId="1" Name="Update" />
             *      <Identity Id="1" Name="0a94fb9f-8071-3000-513c-5633d32c844e|908bed80-a04a-4433-b4a0-883d9847d110:6492ece7-7f5d-4499-8130-50e761e25bd9&#xA;SiteProperties&#xA;https://bertonline.sharepoint.com/sites/prov-1" />
             *  </ObjectPaths>
             * </Request>
             */
            #endregion

            List <ActionObjectPath> actions = new List <ActionObjectPath>();

            var fieldsToUpdate = GetFieldsToUpdate();
            foreach (var field in fieldsToUpdate)
            {
                ActionObjectPath updateProperty = new ActionObjectPath()
                {
                    Action = new SetPropertyAction()
                    {
                        Id           = idProvider.GetActionId(),
                        ObjectPathId = IdentityPath.ToString(),
                        Name         = field.FieldName,
                        SetParameter = new Parameter()
                        {
                            Type  = field.FieldType,
                            Value = field.FieldValue
                        }
                    }
                };

                actions.Add(updateProperty);
            }

            ActionObjectPath spoOperation = new ActionObjectPath()
            {
                Action = new QueryAction()
                {
                    Id           = QueryIdPath,
                    ObjectPathId = updateId.ToString(),
                    SelectQuery  = new SelectQuery()
                    {
                        SelectAllProperties = false,
                        Properties          = new List <Property>()
                        {
                            new Property()
                            {
                                Name = "PollingInterval"
                            },
                            new Property()
                            {
                                Name = "IsComplete"
                            },
                        }
                    }
                }
            };

            ActionObjectPath spoOperation2 = new ActionObjectPath()
            {
                Action = new BaseAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = updateId.ToString()
                },
            };

            ActionObjectPath spoOperation3 = new ActionObjectPath()
            {
                Action = new IdentityQueryAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = IdentityPath.ToString()
                },
            };

            ActionObjectPath updateSitePropertiesAction = new ActionObjectPath()
            {
                ObjectPath = new ObjectPathMethod()
                {
                    Id       = updateId,
                    ParentId = IdentityPath,
                    Name     = "Update"
                }
            };

            ActionObjectPath updateSitePropertiesIdentity = new ActionObjectPath()
            {
                ObjectPath = new Identity()
                {
                    Id   = IdentityPath,
                    Name = Properties.ObjectIdentity.Replace("\n", "&#xA;")
                }
            };

            actions.Add(spoOperation);
            actions.Add(spoOperation2);
            actions.Add(spoOperation3);
            actions.Add(updateSitePropertiesAction);
            actions.Add(updateSitePropertiesIdentity);

            return(actions);
        }
        public List <ActionObjectPath> GetRequest(IIdProvider idProvider)
        {
            IdentityPath = idProvider.GetActionId();
            QueryIdPath  = idProvider.GetActionId();

            #region XML Payload generated

            /*
             *
             * <Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName=".NET Library"
             *  xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
             *  <Actions>
             *      <ObjectPath Id="2" ObjectPathId="1" />
             *      <Query Id="3" ObjectPathId="1">
             *          <Query SelectAllProperties="true">
             *              <Properties />
             *          </Query>
             *      </Query>
             *  </Actions>
             *  <ObjectPaths>
             *      <Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" />
             *  </ObjectPaths>
             * </Request>
             *
             */
            #endregion

            List <ActionObjectPath> actions = new List <ActionObjectPath>();

            ActionObjectPath spoOperation = new ActionObjectPath()
            {
                Action = new BaseAction()
                {
                    Id           = idProvider.GetActionId(),
                    ObjectPathId = IdentityPath.ToString()
                },
            };

            ActionObjectPath spoOperation3 = new ActionObjectPath()
            {
                Action = new QueryAction()
                {
                    Id           = QueryIdPath,
                    ObjectPathId = IdentityPath.ToString(),
                    SelectQuery  = new SelectQuery()
                    {
                        SelectAllProperties = true,
                    }
                },
            };

            ActionObjectPath spoGetSitePropertiesByUrlCollection = new ActionObjectPath()
            {
                ObjectPath = new ConstructorPath
                {
                    Id     = IdentityPath,
                    TypeId = PnPAdminConstants.CsomTenantObject
                }
            };

            actions.Add(spoOperation);
            actions.Add(spoOperation3);
            actions.Add(spoGetSitePropertiesByUrlCollection);

            return(actions);
        }
Esempio n. 6
0
        public void IdentityPathTest()
        {
            SimpleIdentity id = new SimpleIdentity();
            IdentityPath pathSimple = new IdentityPath(id);
            Assert.AreEqual(IdentityPath.ROOT, pathSimple.Parent);
            Assert.AreEqual(IdentityPath.ROOT, pathSimple.GetPathTo(-1));
            Assert.AreEqual(id, pathSimple.Child);
            Assert.AreEqual(1, pathSimple.Length);
            Assert.AreEqual(0, pathSimple.Depth);
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathSimple.GetPathTo(-2));
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathSimple.GetPathTo(1));

            IdentityPath pathRoot = new IdentityPath(new Identity[0]);
            Assert.AreEqual(IdentityPath.ROOT, pathRoot);
            Assert.AreEqual(0, pathRoot.Length);
            Assert.AreEqual(-1, pathRoot.Depth);
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathRoot.Child);
            AssertEx.ThrowsException<IndexOutOfRangeException>(() => pathRoot.Parent);

            const int count = 5;

            List<Identity> listId1 = new List<Identity>();
            List<Identity> listId2 = new List<Identity>();
            HashSet<IdentityPath> setPaths = new HashSet<IdentityPath>();

            IdentityPath last = IdentityPath.ROOT;
            for (int i = 0; i < count; i++)
            {
                listId1.Add(new NumericIdentity(i));
                listId2.Add(new NumericIdentity(i));

                IdentityPath path = new IdentityPath(listId1);
                Assert.AreEqual(path, new IdentityPath(listId1));
                Assert.AreNotEqual(path, new IdentityPath(listId2));
                Assert.AreEqual(last, path.Parent);
                Assert.AreSame(listId1[i], path.Child);
                Assert.AreEqual(path, new IdentityPath(path.Parent, path.Child));
                Assert.AreEqual(i, path.Depth);
                Assert.AreEqual(listId1.Count, path.Length);
                Assert.AreSame(path.Child, path.GetIdentity(path.Depth));
                Assert.AreEqual(path.Parent, path.GetPathTo(path.Depth - 1));
                Assert.AreEqual("/" + listId1.ToString("/"), path.ToString());
                for (int j = 0; j < i; j++)
                    Assert.IsTrue(setPaths.Contains(path.GetPathTo(j)));
                setPaths.Add(path);
                last = path;
            }
        }
        public List <ActionObjectPath> GetRequest(IIdProvider idProvider)
        {
            IdentityPath = idProvider.GetActionId();
            QueryIdPath  = idProvider.GetActionId();
            int updateId = idProvider.GetActionId();

            #region XML Payload generated

            /*
             * <Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="pnp core sdk"
             *  xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
             *  <Actions>
             *      <SetProperty Id="4" ObjectPathId="1" Name="AllowedDomainListForSyncClient">
             *          <Parameter Type="Array"></Parameter>
             *      </SetProperty>
             *      <SetProperty Id="5" ObjectPathId="1" Name="BlockMacSync">
             *          <Parameter Type="Boolean">false</Parameter>
             *      </SetProperty>
             *      <SetProperty Id="6" ObjectPathId="1" Name="ContentTypeSyncSiteTemplatesList">
             *          <Parameter Type="Array"></Parameter>
             *      </SetProperty>
             *      <SetProperty Id="7" ObjectPathId="1" Name="ExcludedFileExtensionsForSyncClient">
             *          <Parameter Type="Array">
             *              <Object Type="String"></Object>
             *          </Parameter>
             *      </SetProperty>
             *  </Actions>
             *  <ObjectPaths>
             *      <Method Id="3" ParentId="1" Name="Update" />
             *      <Identity Id="1" Name="e4d2fd9f-408c-3000-4ada-425ef57c66a4|908bed80-a04a-4433-b4a0-883d9847d110:6492ece7-7f5d-4499-8130-50e761e25bd9&#xA;Tenant" />
             *  </ObjectPaths>
             * </Request>
             */
            #endregion

            List <ActionObjectPath> actions = new List <ActionObjectPath>();

            var fieldsToUpdate = GetFieldsToUpdate();
            foreach (var field in fieldsToUpdate)
            {
                ActionObjectPath updateProperty = new ActionObjectPath()
                {
                    Action = new SetPropertyAction()
                    {
                        Id           = idProvider.GetActionId(),
                        ObjectPathId = IdentityPath.ToString(),
                        Name         = field.FieldName,
                        SetParameter = new Parameter()
                        {
                            Type  = field.FieldType,
                            Value = field.FieldValue
                        }
                    }
                };

                actions.Add(updateProperty);
            }

            ActionObjectPath updateSitePropertiesAction = new ActionObjectPath()
            {
                ObjectPath = new ObjectPathMethod()
                {
                    Id       = updateId,
                    ParentId = IdentityPath,
                    Name     = "Update"
                }
            };

            ActionObjectPath updateSitePropertiesIdentity = new ActionObjectPath()
            {
                ObjectPath = new Identity()
                {
                    Id   = IdentityPath,
                    Name = Properties.ObjectIdentity.Replace("\n", "&#xA;")
                }
            };

            actions.Add(updateSitePropertiesAction);
            actions.Add(updateSitePropertiesIdentity);

            return(actions);
        }