using System; using TestFramework; using TestFramework.ApplicationAPI; namespace Tests.resource { /// <summary> /// Summary description for ResourceCustomField. /// </summary> public class ResourceCustomField : TestHelper { public ResourceCustomField() { // // TODO: Add constructor logic here // } public void x() { { ResourceScope scope = new ResourceScope(); scope.customFieldAssignments =true; TestFramework.ApplicationAPI.Resource test = (TestFramework.ApplicationAPI.Resource) service.loadFromXpath( sessionid, "/Resource[username='salmasri']", scope).rpmObjectList[0]; test.discontinueDate = new DateTime(3000, 1, 1 ); bool found = false; CustomFieldAssignment[] customFieldAssignments = test .customFieldAssignments; for (int i = 0; i < customFieldAssignments.Length; i++) { CustomFieldAssignment assignment = customFieldAssignments[i]; if (assignment.customField.name.Equals("srini")) { assignment.value= "ABC"; found = true; break; } } if ( ! found ) { throw new Exception("Custom field not found"); } SaveResult result = service.save (sessionid, test, scope, ReloadType.None); if ( result.exceptions != null && result.exceptions.Length != 0 ) { throw new Exception("Save Failed"); } } { ResourceScope scope = new ResourceScope(); scope.customFieldAssignments =true; TestFramework.ApplicationAPI.Resource test = (TestFramework.ApplicationAPI.Resource) service.loadFromXpath( sessionid, "/Resource[username='salmasri']", scope).rpmObjectList[0]; bool found = false; CustomFieldAssignment[] customFieldAssignments = test .customFieldAssignments; for (int i = 0; i < customFieldAssignments.Length; i++) { CustomFieldAssignment assignment = customFieldAssignments[i]; if (assignment.customField.name.Equals("srini")) { if(!assignment.value.Equals( "ABC") ) { throw new Exception("Custom field assignment failed"); } found = true; break; } } if ( ! found ) { throw new Exception("Custom field not found"); } } } public void run() { SetUp(); x(); CleanUp(); } } }