Exemple #1
0
        public async Task PatchRemarketings_ShouldReturnOk()
        {
            // Arrange
            var id    = 1;
            var model = new SegmentRemarketingPatchViewModel
            {
                Name = "WJsHome",
                Url  = "www.google.com",
                RemarketingRecency = 1
            };

            Mock.Mock <ISegmentService>().Setup(x => x.GetSegment(id))
            .Returns(Task.FromResult(new Segment()));

            // Act
            var retVal = await Controller.PatchRemarketings(id, model);

            // Assert
            Assert.That(retVal, Is.Not.Null);
            Assert.That(retVal, Is.TypeOf <OkResult>());
            Mock.Mock <ISegmentService>().Verify(x => x.UpdateSegment(It.IsAny <Segment>()), Times.Once);
        }
Exemple #2
0
        public async Task <IHttpActionResult> PatchRemarketings(int id, SegmentRemarketingPatchViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var segment = await _segmentService.GetSegment(id).ConfigureAwait(false);

            if (segment == null)
            {
                return(NotFound());
            }

            _mapping.Map(model, segment);
            await _segmentService.UpdateSegment(segment).ConfigureAwait(false);

            return(Ok());
        }