public void CSOMRequest_Test_ListItemsQueryDeserialization() { string request = "<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\" /><ObjectPath Id=\"6\" ObjectPathId=\"5\" /><ObjectPath Id=\"8\" ObjectPathId=\"7\" /><ObjectIdentityQuery Id=\"9\" ObjectPathId=\"7\" /><ObjectPath Id=\"11\" ObjectPathId=\"10\" /><Query Id=\"12\" ObjectPathId=\"10\"><Query SelectAllProperties=\"true\"><Properties /></Query><ChildItemQuery SelectAllProperties=\"true\"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><StaticProperty Id=\"1\" TypeId=\"{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}\" Name=\"Current\" /><Property Id=\"3\" ParentId=\"1\" Name=\"Web\" /><Property Id=\"5\" ParentId=\"3\" Name=\"Lists\" /><Method Id=\"7\" ParentId=\"5\" Name=\"GetByTitle\"><Parameters><Parameter Type=\"String\">TestList</Parameter></Parameters></Method><Method Id=\"10\" ParentId=\"7\" Name=\"GetItems\"><Parameters><Parameter TypeId=\"{3d248d7b-fc86-40a3-aa97-02a75d69fb8a}\"><Property Name=\"AllowIncrementalResults\" Type=\"Boolean\">false</Property><Property Name=\"DatesInUtc\" Type=\"Boolean\">true</Property><Property Name=\"FolderServerRelativePath\" Type=\"Null\" /><Property Name=\"FolderServerRelativeUrl\" Type=\"Null\" /><Property Name=\"ListItemCollectionPosition\" Type=\"Null\" /><Property Name=\"ViewXml\" Type=\"String\"><View Scope=\"RecursiveAll\"><ViewFields><FieldRef Name=\"Id\" /><FieldRef Name=\"Title\" /><FieldRef Name=\"Author\" /><FieldRef Name=\"Editor\" /></ViewFields><RowLimit>5</RowLimit></View></Property></Parameter></Parameters></Method></ObjectPaths></Request>"; CSOMRequest deserializedRequest = MockEntryResponseProvider.GetRequest(request); ObjectPathMethod getItemsMethod = deserializedRequest.ObjectPaths.Last() as ObjectPathMethod; Assert.AreEqual("{3d248d7b-fc86-40a3-aa97-02a75d69fb8a}", getItemsMethod.Parameters.First().TypeId); Assert.AreEqual(6, getItemsMethod.Parameters.First().Properties.Count); }
public void CreateContentTypeRequest_Test_GenerateCorrectRequest() { IteratorIdProvider idProvider = new IteratorIdProvider(); ContentTypeCreationInfo creationInfo = new ContentTypeCreationInfo() { Id = "0x10023213123123", Description = "Test Description", Group = "Test Group", Name = "Test Name", }; CreateContentTypeRequest request = new CreateContentTypeRequest(creationInfo); List <ActionObjectPath> requests = request.GetRequest(idProvider); var actionRequests = requests.Select(r => r.Action).Where(r => r != null).ToList(); var identities = requests.Select(r => r.ObjectPath).Where(id => id != null).ToList(); BaseAction objectPath = actionRequests[0]; IdentityQueryAction objectIdQuery = actionRequests[1] as IdentityQueryAction; ObjectPathMethod createCTAction = identities[0] as ObjectPathMethod; Property contentTypesProp = identities[1] as Property; Property webProp = identities[2] as Property; StaticProperty currentSiteProp = identities[3] as StaticProperty; Assert.AreEqual("4", objectPath.ObjectPathId); Assert.AreEqual(5, objectPath.Id); Assert.AreEqual("4", objectIdQuery.ObjectPathId); Assert.AreEqual(6, objectIdQuery.Id); Assert.AreEqual("Add", createCTAction.Name); Assert.AreEqual(3, createCTAction.ParentId); Assert.AreEqual(4, createCTAction.Id); Assert.AreEqual("ContentTypes", contentTypesProp.Name); Assert.AreEqual(2, contentTypesProp.ParentId); Assert.AreEqual(3, contentTypesProp.Id); Assert.AreEqual("Web", webProp.Name); Assert.AreEqual(1, webProp.ParentId); Assert.AreEqual(2, webProp.Id); Assert.AreEqual("Current", currentSiteProp.Name); Assert.AreEqual("{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}", currentSiteProp.TypeId); Assert.AreEqual(1, currentSiteProp.Id); }
List <ActionObjectPath> IFieldUpdateStrategy.GetFieldUpdateAction(CSOMItemField fld, Identity identity) { //Get field ObjectPathMethod getFieldByInternalNameMethod = new ObjectPathMethod { Id = IdProvider.GetActionId(), ParentId = FieldsProperty.Id, Name = "GetByInternalNameOrTitle", Parameters = new MethodParameter() { Properties = new List <Parameter>() { new Parameter() { Type = "String", Value = fld.FieldName } } } }; MethodAction setFieldValueByValue = new MethodAction { ObjectPathId = getFieldByInternalNameMethod.Id.ToString(), Id = IdProvider.GetActionId(), Name = "SetFieldValueByValue", Parameters = fld.GetRequestParameters(identity.Id) }; return(new List <ActionObjectPath>() { new ActionObjectPath() { Action = setFieldValueByValue, ObjectPath = getFieldByInternalNameMethod } }); }
List <ActionObjectPath> IFieldUpdateStrategy.GetFieldUpdateAction(CSOMItemField fld, Identity identity) { int getByInternalNameOrTitleId = IdProvider.GetActionId(); int taxonomyParameterConstructorId = IdProvider.GetActionId(); //Set field value MethodAction setFieldValueByValue = new MethodAction { ObjectPathId = getByInternalNameOrTitleId.ToString(), Id = IdProvider.GetActionId(), Name = "SetFieldValueByValueCollection", Parameters = new List <Parameter>() { new ObjectReferenceParameter() { ObjectPathId = identity.Id }, new ObjectReferenceParameter() { ObjectPathId = taxonomyParameterConstructorId } } }; //Get field ObjectPathMethod getFieldByInternalNameMethod = new ObjectPathMethod { Id = getByInternalNameOrTitleId, ParentId = FieldsProperty.Id, Name = "GetByInternalNameOrTitle", Parameters = new MethodParameter() { Properties = new List <Parameter>() { new Parameter() { Type = "String", Value = fld.FieldName } } } }; //Create taxonomy collection List <Parameter> parameters = fld.GetRequestParameters(/*identity.Id*/ getByInternalNameOrTitleId); parameters.Reverse(); ConstructorPath taxonomyCollectionConstructor = new ConstructorPath { Id = taxonomyParameterConstructorId, TypeId = "{c3dfae10-f3bf-4894-9012-bb60665b6d91}", Parameters = new MethodParameter() { Properties = parameters } }; ActionObjectPath setTaxonomyActionObject = new ActionObjectPath() { Action = setFieldValueByValue, ObjectPath = getFieldByInternalNameMethod }; ActionObjectPath constructTaxonomyCollection = new ActionObjectPath() { ObjectPath = taxonomyCollectionConstructor }; return(new List <ActionObjectPath>() { setTaxonomyActionObject, constructTaxonomyCollection }); }
public List <ActionObjectPath> GetRequest(IIdProvider idProvider) { StaticProperty siteProperty = new StaticProperty() { Name = "Current", TypeId = "{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}", Id = idProvider.GetActionId() }; Property web = new Property() { Id = idProvider.GetActionId(), ParentId = siteProperty.Id, Name = "Web" }; Property contentTypes = new Property() { Id = idProvider.GetActionId(), Name = "ContentTypes", ParentId = web.Id }; ObjectPathMethod addCtMethod = new ObjectPathMethod() { Id = idProvider.GetActionId(), ParentId = contentTypes.Id, Name = "Add", Parameters = new MethodParameter() { TypeId = "{168f3091-4554-4f14-8866-b20d48e45b54}", Properties = new List <Parameter>() { new ContentTypeCreationParameter() { Value = ContentTypeCreationInfo } } } }; List <ActionObjectPath> result = new List <ActionObjectPath>(); ActionObjectPath path = new ActionObjectPath() { Action = new BaseAction() { Id = idProvider.GetActionId(), ObjectPathId = addCtMethod.Id.ToString() }, ObjectPath = addCtMethod, }; result.Add(path); ActionObjectPath identityQuery = new ActionObjectPath() { Action = new IdentityQueryAction() { Id = idProvider.GetActionId(), ObjectPathId = addCtMethod.Id.ToString() }, ObjectPath = contentTypes }; result.Add(identityQuery); ActionObjectPath webIdentity = new ActionObjectPath() { ObjectPath = web }; result.Add(webIdentity); ActionObjectPath siteIdentity = new ActionObjectPath() { ObjectPath = siteProperty }; result.Add(siteIdentity); return(result); }