public void Setup() { _jsonHelper = Substitute.For <JsonHelper>(); _actionPatchService = Substitute.For <ActionPatchService>(); _actionPatch = Substitute.For <ActionPatch>(); _json = JsonConvert.SerializeObject(_actionPatch); }
public static void patchAction(ActionPatch patch) { string url = patchActionUrl + patch.id; string body = JsonConvert.SerializeObject(patch); using (HttpRequest req = CreateRequest()) { req.Patch(url, body, "application/json"); } }
public void ActionPatchServiceTests_CheckActionSummaryIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { ActionSummary = "TestActionSummary" }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual("TestActionSummary", action.ActionSummary); }
public void ActionPatchServiceTests_CheckDateActionActuallyCompletedIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { DateActionActuallyCompleted = DateTime.MaxValue }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual(DateTime.MaxValue, action.DateActionActuallyCompleted); }
public void ActionPatchServiceTests_CheckLastModifiedDateIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { LastModifiedDate = DateTime.MaxValue }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual(DateTime.MaxValue, action.LastModifiedDate); }
public void ActionPatchServiceTests_CheckLastModifiedTouchpointIdIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { LastModifiedTouchpointId = "0000000111" }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual("0000000111", action.LastModifiedTouchpointId); }
public void ActionPatchServiceTests_CheckPersonResponsibleIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { PersonResponsible = PersonResponsible.Adviser }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual(PersonResponsible.Adviser, action.PersonResponsible); }
public void ActionPatchServiceTests_CheckActionStatusIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { ActionStatus = ActionStatus.InProgress }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual(ActionStatus.InProgress, action.ActionStatus); }
public void ActionPatchServiceTests_CheckActionTypeIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { ActionType = DSS.Action.ReferenceData.ActionType.ApplyForApprenticeship }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual(ActionType.ApplyForApprenticeship, action.ActionType); }
public void ActionPatchServiceTests_CheckSignpostedToMethodIsUpdated_WhenPatchIsCalled() { var actionPatch = new ActionPatch { SignpostedTo = "SignpostedToTest" }; var patchedAction = _actionPatchService.Patch(_json, actionPatch); var action = JsonConvert.DeserializeObject <Action.Models.Action>(patchedAction); // Assert Assert.AreEqual("SignpostedToTest", action.SignpostedTo); }
public string PatchResource(string actionJson, ActionPatch actionPatch) { if (string.IsNullOrEmpty(actionJson)) { return(null); } if (actionPatch == null) { return(null); } actionPatch.SetDefaultValues(); var updatedAction = _actionPatchService.Patch(actionJson, actionPatch); return(updatedAction); }
public void Setup() { _action = Substitute.For <Models.Action>(); _actionPatch = Substitute.For <ActionPatch>(); _request = new HttpRequestMessage() { Content = new StringContent(string.Empty), RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" + $"Interactions/1e1a555c-9633-4e12-ab28-09ed60d51cb3" + $"ActionPlans/d5369b9a-6959-4bd3-92fc-1583e72b7e51" + $"Actions/233d861d-05ca-496e-aee1-6bd47ac13cb2") }; _log = Substitute.For <ILogger>(); _resourceHelper = Substitute.For <IResourceHelper>(); _validate = Substitute.For <IValidate>(); _httpRequestMessageHelper = Substitute.For <IHttpRequestMessageHelper>(); _patchActionHttpTriggerService = Substitute.For <IPatchActionHttpTriggerService>(); _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001"); _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/"); _patchActionHttpTriggerService.PatchResource(Arg.Any <string>(), _actionPatch).Returns(_action.ToString()); }
public string Patch(string actionJson, ActionPatch actionPatch) { if (string.IsNullOrEmpty(actionJson)) { return(null); } var obj = JObject.Parse(actionJson); if (actionPatch.DateActionAgreed.HasValue) { JsonHelper.UpdatePropertyValue(obj["DateActionAgreed"], actionPatch.DateActionAgreed); } if (actionPatch.DateActionAimsToBeCompletedBy.HasValue) { JsonHelper.UpdatePropertyValue(obj["DateActionAimsToBeCompletedBy"], actionPatch.DateActionAimsToBeCompletedBy); } if (actionPatch.DateActionActuallyCompleted.HasValue) { JsonHelper.UpdatePropertyValue(obj["DateActionActuallyCompleted"], actionPatch.DateActionActuallyCompleted); } if (!string.IsNullOrEmpty(actionPatch.ActionSummary)) { JsonHelper.UpdatePropertyValue(obj["ActionSummary"], actionPatch.ActionSummary); } if (!string.IsNullOrEmpty(actionPatch.SignpostedTo)) { JsonHelper.UpdatePropertyValue(obj["SignpostedTo"], actionPatch.SignpostedTo); } if (actionPatch.ActionType.HasValue) { JsonHelper.UpdatePropertyValue(obj["ActionType"], actionPatch.ActionType); } if (actionPatch.ActionStatus.HasValue) { JsonHelper.UpdatePropertyValue(obj["ActionStatus"], actionPatch.ActionStatus); } if (actionPatch.PersonResponsible.HasValue) { JsonHelper.UpdatePropertyValue(obj["PersonResponsible"], actionPatch.PersonResponsible); } if (actionPatch.LastModifiedDate.HasValue) { JsonHelper.UpdatePropertyValue(obj["LastModifiedDate"], actionPatch.LastModifiedDate); } if (!string.IsNullOrEmpty(actionPatch.LastModifiedTouchpointId)) { JsonHelper.UpdatePropertyValue(obj["LastModifiedTouchpointId"], actionPatch.LastModifiedTouchpointId); } if (!string.IsNullOrEmpty(actionPatch.LastModifiedTouchpointId)) { JsonHelper.UpdatePropertyValue(obj["LastModifiedTouchpointId"], actionPatch.LastModifiedTouchpointId); } return(obj.ToString()); }