public void FieldsToJArray_UnitTest()
        {
            JsonWorkItem workItem = default(JsonWorkItem);
            JArray       _retVal  = default(JArray);

            ExecuteMethod(
                () => { return(GetInstance()); },
                instance =>
            {
                workItem = default(JsonWorkItem);     //No Constructor
                FieldsToJArray_PreCondition(instance, ref workItem);
            },
                instance => { return(_retVal = JsonWorkItem.FieldsToJArray(workItem)); },
                instance => { FieldsToJArray_PostValidate(instance, workItem, _retVal); });
        }
Пример #2
0
        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);
        }
Пример #3
0
        /// <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&lt;JsonWorkItem&gt;.</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);
        }