public void UpdatePropertyBag_Test_BuildUpdateFileProperty() { FilePropertyBagUpdateRequest updatePropertyBagRequest = new FilePropertyBagUpdateRequest("/sites/test-sites/some-test-folder/test-file.docx") { SiteId = "test-site-id", WebId = "test-web-id" }; updatePropertyBagRequest.FieldsToUpdate.Add(new CSOMItemField() { FieldName = "TestProperty", FieldValue = "TestPropertyValue", FieldType = "String" }); IIdProvider idProvider = new IteratorIdProvider(); var request = updatePropertyBagRequest.GetRequest(idProvider); var firstPart = request[0]; var secondPart = request[1]; string setValuePart = "<Method Name=\"SetFieldValue\" Id=\"1\" ObjectPathId=\"3\"><Parameters><Parameter Type=\"String\">TestProperty</Parameter><Parameter Type=\"String\">TestPropertyValue</Parameter></Parameters></Method>"; string allPropertiesPath = "<Property Id=\"3\" ParentId=\"2\" Name=\"Properties\" />"; string updatePropertiesMethod = "<Method Name=\"Update\" Id=\"1\" ObjectPathId=\"2\"></Method>"; string webIdentity = "<Identity Id=\"2\" Name=\"121a659f-e03e-2000-4281-1212829d67dd|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:test-site-id:web:test-web-id:file:/sites/test-sites/some-test-folder/test-file.docx\" />"; Assert.AreEqual(setValuePart, firstPart.Action.ToString()); Assert.AreEqual(allPropertiesPath, firstPart.ObjectPath.ToString()); Assert.AreEqual(updatePropertiesMethod, secondPart.Action.ToString()); Assert.AreEqual(webIdentity, secondPart.ObjectPath.ToString()); }
public void UpdateOvervriteVersionRequest_Test_ProcessRequest() { UpdateListItemRequest request = new UpdateOverwriteVersionRequest("test-site-id", "test-web-id", "test-list-id", 1); request.FieldsToUpdate.Add(new CSOMItemField() { FieldName = "Title", FieldType = "String", FieldValue = "Test field value" }); IIdProvider idProvider = new IteratorIdProvider(); request.GetRequest(idProvider); request.ProcessResponse("[1,{\"_ObjectType_\":\"SP.ListItem\", \"_ObjectIdentity_\":\"10f1b19f-b09b-2000-a0c6-8d8859432e0d|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:69399214-4542-4f93-b658-328a712a834f:web:f5ad2fe7-d9f1-4b96-8dce-884fa6cc49cd:list:98f73a1b-9869-4024-af86-9e63da385636:item:1,1\", \"_ObjectVersion_\":\"2\", \"Title\":\"Test field value\"}]"); Assert.AreEqual("Test field value", request.Result.Title); }
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); }
public void UpdateOvervriteVersionRequest_Test_GetRequest() { UpdateListItemRequest request = new UpdateOverwriteVersionRequest("test-site-id", "test-web-id", "test-list-id", 1); request.FieldsToUpdate.Add(new CSOMItemField() { FieldName = "Test Field", FieldType = "String", FieldValue = "Test field value" }); IIdProvider idProvider = new IteratorIdProvider(); List <ActionObjectPath> actionObjectPaths = request.GetRequest(idProvider); ActionObjectPath setFieldsActionPath = actionObjectPaths[0]; Assert.AreEqual("<Method Name=\"SetFieldValue\" Id=\"4\" ObjectPathId=\"1\"><Parameters><Parameter Type=\"String\">Test Field</Parameter><Parameter Type=\"String\">Test field value</Parameter></Parameters></Method>", setFieldsActionPath.Action.ToString()); ActionObjectPath actionObjectPath = actionObjectPaths[1]; Assert.AreEqual("<Method Name=\"UpdateOverwriteVersion\" Id=\"5\" ObjectPathId=\"1\"></Method>", actionObjectPath.Action.ToString()); Assert.AreEqual("<Identity Id=\"1\" Name=\"121a659f-e03e-2000-4281-1212829d67dd|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:test-site-id:web:test-web-id:list:test-list-id:item:1,1\" />", actionObjectPath.ObjectPath.ToString()); }