internal static JsonWorkItem GetInstance([CallerMemberName] string callerName = "") { JToken json = new JObject(); JsonSource(ref json); JsonWorkItem instance = JsonWorkItem.FromToken(json); InstanceFactory(ref instance, callerName); return(instance); }
public void FromToken_UnitTest() { JToken json = default(JToken); JsonWorkItem _retVal = default(JsonWorkItem); ExecuteMethod( () => { return(GetInstance()); }, instance => { json = default(JToken); //No Constructor FromToken_PreCondition(instance, ref json); }, instance => { return(_retVal = JsonWorkItem.FromToken(json)); }, instance => { FromToken_PostValidate(instance, json, _retVal); }); }
public async Task <JsonWorkItem> UpdateWorkItem(JsonWorkItem workItem) { JArray elements = JsonWorkItem.FieldsToJArray(workItem); string body = ToJsonString(elements); var exchange = StructuredHttpExchange.Patch(WitRestCalls.WorkItem, body); exchange.SetRoute("{id}", workItem.Id); JsonWorkItem result = await ProcessCollectionRequest(exchange, jObject => { JsonWorkItem newWorkItem = JsonWorkItem.FromToken(jObject); return(newWorkItem); }); return(result); }
/// <summary> /// Creates the work item. /// </summary> /// <param name="project">The project.</param> /// <param name="workItemType">Type of the work item.</param> /// <param name="workItem">The work item.</param> /// <param name="inPlaceUpdate">if set to <c>true</c> [in place update].</param> /// <returns>Task<JsonWorkItem>.</returns> public async Task <JsonWorkItem> CreateWorkItem(string project, string workItemType, JsonWorkItem workItem, bool inPlaceUpdate) { JArray elements = JsonWorkItem.FieldsToJArray(workItem); var body = ToJsonString(elements); var exchange = StructuredHttpExchange.Patch(WitRestCalls.WorkItems1, body); exchange.SetRoute("{type}", workItemType.Replace(" ", "%20")); JsonWorkItem result = await ProcessProjectRequest(project, exchange, jObject => { if (inPlaceUpdate) { workItem.CaptureJson(jObject); return(workItem); } var newWorkItem = JsonWorkItem.FromToken(jObject); return(newWorkItem); }); return(result); }