public void Setup()
        {
            _jsonHelper          = Substitute.For <JsonHelper>();
            _outcomePatchService = Substitute.For <OutcomePatchService>();
            _outcomePatch        = Substitute.For <OutcomesPatch>();

            _json = JsonConvert.SerializeObject(_outcomePatch);
        }
        public void OutcomesPatchServiceTests_CheckTouchpointId_WhenPatchIsCalled()
        {
            var diversityPatch = new OutcomesPatch {
                TouchpointId = "0000000111"
            };

            var patchedOutcome = _outcomePatchService.Patch(_json, diversityPatch);

            var outcome = JsonConvert.DeserializeObject <Models.Outcomes>(patchedOutcome);

            var touchpointId = outcome.TouchpointId;

            // Assert
            Assert.AreEqual("0000000111", touchpointId);
        }
        public void OutcomesPatchServiceTests_CheckOutcomeClaimedDateIsUpdated_WhenPatchIsCalled()
        {
            var diversityPatch = new OutcomesPatch {
                OutcomeClaimedDate = DateTime.MaxValue
            };

            var patchedOutcome = _outcomePatchService.Patch(_json, diversityPatch);

            var outcome = JsonConvert.DeserializeObject <Models.Outcomes>(patchedOutcome);

            var outcomeClaimedDate = outcome.OutcomeClaimedDate;

            // Assert
            Assert.AreEqual(DateTime.MaxValue, outcomeClaimedDate);
        }
        public void OutcomesPatchServiceTests_CheckOutcomeTypeIsUpdated_WhenPatchIsCalled()
        {
            var diversityPatch = new OutcomesPatch {
                OutcomeType = OutcomeType.CareerProgression
            };

            var patchedOutcome = _outcomePatchService.Patch(_json, diversityPatch);

            var outcome = JsonConvert.DeserializeObject <Models.Outcomes>(patchedOutcome);

            var outcomeType = outcome.OutcomeType;

            // Assert
            Assert.AreEqual(OutcomeType.CareerProgression, outcomeType);
        }
        public void Setup()
        {
            _outcome      = Substitute.For <Models.Outcomes>();
            _outcomePatch = Substitute.For <OutcomesPatch>();

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

            _log            = Substitute.For <ILogger>();
            _resourceHelper = Substitute.For <IResourceHelper>();
            _deleteOutcomesHttpTriggerService = Substitute.For <IDeleteOutcomesHttpTriggerService>();
        }
        public string PatchResource(string outcomeJson, OutcomesPatch outcomesPatchPatch)
        {
            if (string.IsNullOrEmpty(outcomeJson))
            {
                return(null);
            }

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

            outcomesPatchPatch.SetDefaultValues();

            var updatedOutcome = _outcomePatchService.Patch(outcomeJson, outcomesPatchPatch);

            return(updatedOutcome);
        }
Ejemplo n.º 7
0
        public string Patch(string outcomeJson, OutcomesPatch outcomePatch)
        {
            if (string.IsNullOrEmpty(outcomeJson))
            {
                return(null);
            }

            var obj = JObject.Parse(outcomeJson);

            if (outcomePatch.OutcomeType.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["OutcomeType"], outcomePatch.OutcomeType);
            }

            if (outcomePatch.OutcomeClaimedDate.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["OutcomeClaimedDate"], outcomePatch.OutcomeClaimedDate.Value);
            }

            if (outcomePatch.OutcomeEffectiveDate.HasValue)
            {
                JsonHelper.UpdatePropertyValue(obj["OutcomeEffectiveDate"], outcomePatch.OutcomeEffectiveDate);
            }

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

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

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

            return(obj.ToString());
        }
Ejemplo n.º 8
0
        public void Setup()
        {
            _outcome      = Substitute.For <Models.Outcomes>();
            _outcomePatch = Substitute.For <OutcomesPatch>();

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

            _log                             = Substitute.For <ILogger>();
            _resourceHelper                  = Substitute.For <IResourceHelper>();
            _validate                        = Substitute.For <IValidate>();
            _httpRequestMessageHelper        = Substitute.For <IHttpRequestMessageHelper>();
            _patchOutcomesHttpTriggerService = Substitute.For <IPatchOutcomesHttpTriggerService>();
            _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001");
            _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/");
        }