public void SuccessTest() { var errors = new List<string> {"Error"}; var target = new OperationResult() { Errors= errors }; Assert.IsFalse(target.Success); errors.Clear(); Assert.IsTrue(target.Success); }
/// <summary> /// Update the item described by the specified type and object id with /// the fields of the specified object /// </summary> /// <param name="typePath">the type of the item to be updated</param> /// <param name="oid">the object id of the item to be updated</param> /// <param name="obj">the object fields to update</param> /// <returns>An <see cref="OperationResult"/> describing the status of the request</returns> /// <exception cref="RallyUnavailableException">Rally returned an HTML page. This usually occurs when Rally is off-line. Please check the ErrorMessage property for more information.</exception> /// <exception cref="RallyFailedToDeserializeJson">The JSON returned by Rally was not able to be deserialized. Please check the JsonData property for what was returned by Rally.</exception> /// <example> /// <code language="C#"> /// DynamicJsonObject toUpdate = new DynamicJsonObject(); /// toUpdate["Description"] = "This is my defect."; /// OperationResult updateResult = restApi.Update("defect", "12345", toUpdate); /// </code> /// </example> public OperationResult Update(string typePath, string oid, DynamicJsonObject obj) { if (ConnectionInfo == null) throw new InvalidOperationException(AUTH_ERROR); var result = new OperationResult(); var data = new DynamicJsonObject(); data[typePath] = obj; dynamic response = DoPost(FormatUpdateUri(typePath, oid), data); if (response.OperationResult["Object"] != null) result.Object = response.OperationResult.Object; result.Errors.AddRange(DecodeArrayList(response.OperationResult.Errors)); result.Warnings.AddRange(DecodeArrayList(response.OperationResult.Warnings)); return result; }
/// <summary> /// Delete the object described by the specified reference. /// </summary> /// <param name="workspaceRef">the workspace from which the object will be deleted. Null means that the server will pick a workspace.</param> /// <param name="aRef">the reference</param> /// <returns>An OperationResult with information on the status of the request</returns> /// <exception cref="RallyUnavailableException">Rally returned an HTML page. This usually occurs when Rally is off-line. Please check the ErrorMessage property for more information.</exception> /// <exception cref="RallyFailedToDeserializeJson">The JSON returned by Rally was not able to be deserialized. Please check the JsonData property for what was returned by Rally.</exception> /// <example> /// <code language="C#"> /// string workspaceRef = "/workspace/12345678910";; /// string objectRef = "/defect/12345678912"; /// OperationResult deleteResult = restApi.Delete(workspaceRef, objectRef); ///</code> ///</example> public OperationResult Delete(string workspaceRef, string aRef) { if (ConnectionInfo == null) throw new InvalidOperationException(AUTH_ERROR); var result = new OperationResult(); if (!aRef.Contains(".js")) { aRef = aRef + ".js"; } String workspaceClause = workspaceRef == null ? "" : "?workspace=" + workspaceRef; dynamic response = DoDelete(GetFullyQualifiedUri(aRef + workspaceClause)); result.Errors.AddRange(DecodeArrayList(response.OperationResult.Errors)); result.Warnings.AddRange(DecodeArrayList(response.OperationResult.Warnings)); return result; }
/// <summary> /// Update the item described by the specified type and object id with /// the fields of the specified object /// </summary> /// <param name="typePath">the type of the item to be updated</param> /// <param name="oid">the object id of the item to be updated</param> /// <param name="obj">the object fields to update</param> /// <returns>An <see cref="OperationResult"/> describing the status of the request</returns> /// <exception cref="RallyUnavailableException">Rally returned an HTML page. This usually occurs when Rally is off-line. Please check the ErrorMessage property for more information.</exception> /// <exception cref="RallyFailedToDeserializeJson">The JSON returned by Rally was not able to be deserialized. Please check the JsonData property for what was returned by Rally.</exception> /// <example> /// <code language="C#"> /// DynamicJsonObject toUpdate = new DynamicJsonObject(); /// toUpdate["Description"] = "This is my defect."; /// OperationResult updateResult = restApi.Update("defect", "12345", toUpdate); /// </code> /// </example> public OperationResult Update(string typePath, string oid, DynamicJsonObject obj) { if (ConnectionInfo == null) throw new InvalidOperationException("You must authenticate against Rally prior to performing any data operations."); var result = new OperationResult(); var data = new DynamicJsonObject(); data[typePath] = obj; dynamic response = DoPost(FormatUpdateUri(typePath, oid), data); if (response.OperationResult["Object"] != null) result.Object = response.OperationResult.Object; result.Errors.AddRange(DecodeArrayList(response.OperationResult.Errors)); result.Warnings.AddRange(DecodeArrayList(response.OperationResult.Warnings)); return result; }
private OperationResult UpdateCollection(string itemRef, string collectionName, List<DynamicJsonObject> items, NameValueCollection parameters, bool adding) { if (ConnectionInfo == null) { throw new InvalidOperationException(AUTH_ERROR); } var result = new OperationResult(); var data = new DynamicJsonObject(); data["CollectionItems"] = items; dynamic response = DoPost(FormatUpdateCollectionUri(adding, itemRef, collectionName, parameters), data); if(response.OperationResult.HasMember("Results")) { result.Results.AddRange((response.OperationResult.Results as ArrayList).Cast<DynamicJsonObject>()); } result.Errors.AddRange(DecodeArrayList(response.OperationResult.Errors)); result.Warnings.AddRange(DecodeArrayList(response.OperationResult.Warnings)); return result; }
/// <summary> /// Update the item described by the specified type and object id with /// the fields of the specified object /// </summary> /// <param name="typePath">the type of the item to be updated</param> /// <param name="oid">the object id of the item to be updated</param> /// <param name="obj">the object fields to update</param> /// <returns>An OperationResult describing the status of the request</returns> public OperationResult Update(string typePath, string oid, DynamicJsonObject obj) { var result = new OperationResult(); var data = new DynamicJsonObject(); data[typePath] = obj; dynamic response = DoPost(FormatUpdateUri(typePath, oid), data); result.Errors.AddRange(DecodeArrayList(response.OperationResult.Errors)); result.Warnings.AddRange(DecodeArrayList(response.OperationResult.Warnings)); return result; }