Exemplo n.º 1
0
        public void Setup()
        {
            _adviserDetailPatchService = Substitute.For <AdviserDetailPatchService>();
            _adviserDetailPatch        = Substitute.For <AdviserDetailPatch>();

            _json = JsonConvert.SerializeObject(_adviserDetailPatch);
        }
Exemplo n.º 2
0
        public void AdviserDetailPatchServiceTests_CheckLastModifiedByUpdated_WhenPatchIsCalled()
        {
            var adviserDetailPatch = new AdviserDetailPatch {
                LastModifiedTouchpointId = "0000000111"
            };

            var patchedAdviserDetail = _adviserDetailPatchService.Patch(_json, adviserDetailPatch);

            var adviserDetail = JsonConvert.DeserializeObject <Models.AdviserDetail>(patchedAdviserDetail);

            // Assert
            Assert.AreEqual("0000000111", adviserDetail.LastModifiedTouchpointId);
        }
Exemplo n.º 3
0
        public void AdviserDetailPatchServiceTests_CheckLastModifiedDateIsUpdated_WhenPatchIsCalled()
        {
            var adviserDetailPatch = new AdviserDetailPatch {
                LastModifiedDate = DateTime.MaxValue
            };

            var patchedAdviserDetail = _adviserDetailPatchService.Patch(_json, adviserDetailPatch);

            var adviserDetail = JsonConvert.DeserializeObject <Models.AdviserDetail>(patchedAdviserDetail);

            // Assert
            Assert.AreEqual(DateTime.MaxValue, adviserDetail.LastModifiedDate);
        }
Exemplo n.º 4
0
        public void AdviserDetailPatchServiceTests_CheckAdviserDetailAdviserEmailAddressIsUpdated_WhenPatchIsCalled()
        {
            var adviserDetailPatch = new AdviserDetailPatch {
                AdviserEmailAddress = "*****@*****.**"
            };

            var patchedAdviserDetail = _adviserDetailPatchService.Patch(_json, adviserDetailPatch);

            var adviserDetail = JsonConvert.DeserializeObject <Models.AdviserDetail>(patchedAdviserDetail);

            // Assert
            Assert.AreEqual("*****@*****.**", adviserDetail.AdviserEmailAddress);
        }
Exemplo n.º 5
0
        public void AdviserDetailPatchServiceTests_CheckAdviserDetailAdviserContactNumberIsUpdated_WhenPatchIsCalled()
        {
            var adviserDetailPatch = new AdviserDetailPatch {
                AdviserContactNumber = "1111"
            };

            var patchedAdviserDetail = _adviserDetailPatchService.Patch(_json, adviserDetailPatch);

            var adviserDetail = JsonConvert.DeserializeObject <Models.AdviserDetail>(patchedAdviserDetail);

            // Assert
            Assert.AreEqual("1111", adviserDetail.AdviserContactNumber);
        }
        public string PatchResource(string adviserDetailJson, AdviserDetailPatch adviserDetailPatch)
        {
            if (string.IsNullOrEmpty(adviserDetailJson))
            {
                return(null);
            }

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

            adviserDetailPatch.SetDefaultValues();

            var updatedAdviserDetail = _adviserDetailPatchService.Patch(adviserDetailJson, adviserDetailPatch);

            return(updatedAdviserDetail);
        }
        public string Patch(string adviserDetailJson, AdviserDetailPatch adviserDetailPatch)
        {
            if (string.IsNullOrEmpty(adviserDetailJson))
            {
                return(null);
            }

            var obj = JObject.Parse(adviserDetailJson);

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

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

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

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

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

            return(obj.ToString());
        }