示例#1
0
        public void Setup()
        {
            _jsonHelper             = Substitute.For <JsonHelper>();
            _actionPlanPatchService = Substitute.For <ActionPlanPatchService>();
            _actionPlanPatch        = Substitute.For <ActionPlanPatch>();

            _json = JsonConvert.SerializeObject(_actionPlanPatch);
        }
示例#2
0
        public void ActionPlanPatchServiceTests_CheckCustomerCharterShownToCustomerIsUpdated_WhenPatchIsCalled()
        {
            var actionPlanPatch = new ActionPlanPatch {
                CustomerCharterShownToCustomer = true
            };

            var patchedActionPlan = _actionPlanPatchService.Patch(_json, actionPlanPatch);

            var actionPlan = JsonConvert.DeserializeObject <Models.ActionPlan>(patchedActionPlan);

            var customerCharterShownToCustomer = actionPlan.CustomerCharterShownToCustomer;

            // Assert
            Assert.AreEqual(true, customerCharterShownToCustomer);
        }
示例#3
0
        public void ActionPlanPatchServiceTests_CheckLastModifiedDateIsUpdated_WhenPatchIsCalled()
        {
            var actionPlanPatch = new ActionPlanPatch {
                LastModifiedDate = DateTime.MaxValue
            };

            var patchedActionPlan = _actionPlanPatchService.Patch(_json, actionPlanPatch);

            var actionPlan = JsonConvert.DeserializeObject <Models.ActionPlan>(patchedActionPlan);

            var lastModifiedDate = actionPlan.LastModifiedDate;

            // Assert
            Assert.AreEqual(DateTime.MaxValue, lastModifiedDate);
        }
示例#4
0
        public void ActionPlanPatchServiceTests_CheckLastModifiedTouchpointIdIsUpdated_WhenPatchIsCalled()
        {
            var actionPlanPatch = new ActionPlanPatch {
                LastModifiedTouchpointId = "0000000111"
            };

            var patchedActionPlan = _actionPlanPatchService.Patch(_json, actionPlanPatch);

            var actionPlan = JsonConvert.DeserializeObject <Models.ActionPlan>(patchedActionPlan);

            var lastModifiedTouchpointId = actionPlan.LastModifiedTouchpointId;

            // Assert
            Assert.AreEqual("0000000111", lastModifiedTouchpointId);
        }
示例#5
0
        public void ActionPlanPatchServiceTests_CheckCurrentSituationIsUpdated_WhenPatchIsCalled()
        {
            var actionPlanPatch = new ActionPlanPatch {
                CurrentSituation = "Current"
            };

            var patchedActionPlan = _actionPlanPatchService.Patch(_json, actionPlanPatch);

            var actionPlan = JsonConvert.DeserializeObject <Models.ActionPlan>(patchedActionPlan);

            var currentSituation = actionPlan.CurrentSituation;

            // Assert
            Assert.AreEqual("Current", currentSituation);
        }
示例#6
0
        public void ActionPlanPatchServiceTests_CheckActionPlanDeliveryMethodIsUpdated_WhenPatchIsCalled()
        {
            var actionPlanPatch = new ActionPlanPatch {
                ActionPlanDeliveryMethod = ActionPlanDeliveryMethod.Paper
            };

            var patchedActionPlan = _actionPlanPatchService.Patch(_json, actionPlanPatch);

            var actionPlan = JsonConvert.DeserializeObject <Models.ActionPlan>(patchedActionPlan);

            var actionPlanDeliveryMethod = actionPlan.ActionPlanDeliveryMethod;

            // Assert
            Assert.AreEqual(ActionPlanDeliveryMethod.Paper, actionPlanDeliveryMethod);
        }
示例#7
0
        public void ActionPlanPatchServiceTests_CheckDateActionPlanCreatedIsUpdated_WhenPatchIsCalled()
        {
            var actionPlanPatch = new ActionPlanPatch()
            {
                DateActionPlanCreated = DateTime.MaxValue
            };

            var patchedActionPlan = _actionPlanPatchService.Patch(_json, actionPlanPatch);

            var actionPlan = JsonConvert.DeserializeObject <Models.ActionPlan>(patchedActionPlan);

            var dateActionPlanCreated = actionPlan.DateActionPlanCreated;

            // Assert
            Assert.AreEqual(DateTime.MaxValue, dateActionPlanCreated);
        }
示例#8
0
        public string PatchResource(string actionPlanJson, ActionPlanPatch actionPlanPatch)
        {
            if (string.IsNullOrEmpty(actionPlanJson))
            {
                return(null);
            }

            if (actionPlanPatch == null)
            {
                return(null);
            }

            actionPlanPatch.SetDefaultValues();

            var updatedActionPlan = _actionPlanPatchService.Patch(actionPlanJson, actionPlanPatch);

            return(updatedActionPlan);
        }
示例#9
0
        public void Setup()
        {
            _actionPlan      = Substitute.For <Models.ActionPlan>();
            _actionPlanPatch = Substitute.For <ActionPlanPatch>();

            _request = new HttpRequestMessage()
            {
                Content    = new StringContent(string.Empty),
                RequestUri =
                    new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/" +
                            $"ActionPlans/1e1a555c-9633-4e12-ab28-09ed60d51cb3")
            };

            _log                               = Substitute.For <ILogger>();
            _resourceHelper                    = Substitute.For <IResourceHelper>();
            _validate                          = Substitute.For <IValidate>();
            _httpRequestMessageHelper          = Substitute.For <IHttpRequestMessageHelper>();
            _patchActionPlanHttpTriggerService = Substitute.For <IPatchActionPlanHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
            _patchActionPlanHttpTriggerService.PatchResource(Arg.Any <string>(), _actionPlanPatch).Returns(_actionPlan.ToString());
        }
        public string Patch(string actionPlanJson, ActionPlanPatch actionPlanPatch)
        {
            if (string.IsNullOrEmpty(actionPlanJson))
            {
                return(null);
            }

            var obj = JObject.Parse(actionPlanJson);

            if (actionPlanPatch.DateActionPlanCreated.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["DateActionPlanCreated"], actionPlanPatch.DateActionPlanCreated);
            }

            if (actionPlanPatch.CustomerCharterShownToCustomer.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["CustomerCharterShownToCustomer"], actionPlanPatch.CustomerCharterShownToCustomer);
            }

            if (actionPlanPatch.DateAndTimeCharterShown.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["DateAndTimeCharterShown"], actionPlanPatch.DateAndTimeCharterShown);
            }

            if (actionPlanPatch.DateActionPlanSentToCustomer.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["DateActionPlanSentToCustomer"], actionPlanPatch.DateActionPlanSentToCustomer);
            }

            if (actionPlanPatch.ActionPlanDeliveryMethod.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["ActionPlanDeliveryMethod"], actionPlanPatch.ActionPlanDeliveryMethod);
            }

            if (actionPlanPatch.DateActionPlanAcknowledged.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["DateActionPlanAcknowledged"], actionPlanPatch.DateActionPlanAcknowledged);
            }

            if (actionPlanPatch.PriorityCustomer.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["PriorityCustomer"], actionPlanPatch.PriorityCustomer);
            }

            if (!string.IsNullOrEmpty(actionPlanPatch.CurrentSituation))
            {
                JsonHelper.UpdatePropertyValue(obj["CurrentSituation"], actionPlanPatch.CurrentSituation);
            }

            if (actionPlanPatch.LastModifiedDate.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["LastModifiedDate"], actionPlanPatch.LastModifiedDate);
            }

            if (!string.IsNullOrEmpty(actionPlanPatch.LastModifiedTouchpointId))
            {
                JsonHelper.UpdatePropertyValue(obj["LastModifiedTouchpointId"], actionPlanPatch.LastModifiedTouchpointId);
            }

            return(obj.ToString());
        }