Exemplo n.º 1
0
        public void JobProfileServiceUpdateReturnsSuccessWhenProfileUpdated()
        {
            // arrange
            var jobProfileModel         = A.Fake <JobProfileModel>();
            var existingJobProfileModel = A.Fake <JobProfileModel>();
            var expectedResult          = HttpStatusCode.OK;

            A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileModel, bool> > > .Ignored)).Returns(existingJobProfileModel);
            A.CallTo(() => repository.UpsertAsync(A <JobProfileModel> .Ignored)).Returns(expectedResult);

            // act
            var result = jobProfileService.Update(jobProfileModel).Result;

            // assert
            A.CallTo(() => repository.GetAsync(A <Expression <Func <JobProfileModel, bool> > > .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => mapper.Map(jobProfileModel, existingJobProfileModel)).MustHaveHappenedOnceExactly();
            A.CallTo(() => repository.UpsertAsync(A <JobProfileModel> .Ignored)).MustHaveHappenedOnceExactly();
            A.Equals(result, expectedResult);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Update([FromBody] JobProfileModel jobProfileModel)
        {
            //AOP: These should be coded as an Aspect
            logService.LogInformation($"{nameof(Create)} has been called with {jobProfileModel?.JobProfileId} for {jobProfileModel?.CanonicalName} with seq number {jobProfileModel?.SequenceNumber}");

            if (jobProfileModel is null)
            {
                return(BadRequest());
            }

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

            var response = await jobProfileService.Update(jobProfileModel).ConfigureAwait(false);

            logService.LogInformation($"{nameof(Create)} has upserted content for: {jobProfileModel.CanonicalName} - Response - {response}");
            return(new StatusCodeResult((int)response));
        }