public override void Given() { var profileId = 1; var uln = 1234567890; ViewModel = new ChangeLearnersNameViewModel { ProfileId = profileId, Firstname = reqFirstName, Lastname = reqLastName }; mockRegDetails = new RegistrationDetails { Firstname = existingFirstName, Lastname = existingLastName, Uln = uln, ProfileId = profileId, }; InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ViewModel.ProfileId, RegistrationPathwayStatus.Active) .Returns(mockRegDetails); InternalApiClient.UpdateRegistrationAsync(Arg.Is <ManageRegistration> (x => x.Uln == mockRegDetails.Uln && x.ProfileId == mockRegDetails.ProfileId && x.FirstName == ViewModel.Firstname && x.LastName == ViewModel.Lastname)) .Returns(true); }
public override void Given() { ViewModel = new ChangeLearnersNameViewModel { ProfileId = 1 }; InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, Arg.Any <int>(), RegistrationPathwayStatus.Active) .Returns(mockResponse); }
public override void Given() { mockresult = new ChangeLearnersNameViewModel { ProfileId = 1, Firstname = "John", Lastname = "Smith", }; RegistrationLoader.GetRegistrationProfileAsync <ChangeLearnersNameViewModel>(AoUkprn, ProfileId).Returns(mockresult); }
public override void Given() { ViewModel = new ChangeLearnersNameViewModel { ProfileId = 1, Firstname = firstName, Lastname = lastName }; regDetailsMock = new RegistrationDetails { Firstname = firstName.Trim().ToUpper(), Lastname = lastName.Trim().ToUpper() }; InternalApiClient.GetRegistrationDetailsAsync(AoUkprn, ViewModel.ProfileId, RegistrationPathwayStatus.Active) .Returns(regDetailsMock); }
public override void Setup() { HttpContextAccessor = Substitute.For <IHttpContextAccessor>(); RegistrationLoader = Substitute.For <IRegistrationLoader>(); CacheService = Substitute.For <ICacheService>(); Logger = Substitute.For <ILogger <ManageRegistrationController> >(); Controller = new ManageRegistrationController(RegistrationLoader, CacheService, Logger); AoUkprn = 1234567890; var httpContext = new ClaimsIdentityBuilder <ManageRegistrationController>(Controller) .Add(CustomClaimTypes.Ukprn, AoUkprn.ToString()) .Add(CustomClaimTypes.UserId, Guid.NewGuid().ToString()) .Build() .HttpContext; HttpContextAccessor.HttpContext.Returns(httpContext); CacheKey = CacheKeyHelper.GetCacheKey(httpContext.User.GetUserId(), CacheConstants.RegistrationCacheKey); ViewModel = new ChangeLearnersNameViewModel(); MockResult = new ManageRegistrationResponse(); }
public async override Task When() { ActualResult = await Loader.GetRegistrationProfileAsync <ChangeLearnersNameViewModel>(AoUkprn, ProfileId); }
public async Task <ManageRegistrationResponse> ProcessProfileNameChangeAsync(long aoUkprn, ChangeLearnersNameViewModel viewModel) { var reg = await _internalApiClient.GetRegistrationDetailsAsync(aoUkprn, viewModel.ProfileId, RegistrationPathwayStatus.Active); if (reg == null) { return(null); } if (viewModel.Firstname.Trim().Equals(reg.Firstname, StringComparison.InvariantCultureIgnoreCase) && viewModel.Lastname.Trim().Equals(reg.Lastname, StringComparison.InvariantCultureIgnoreCase)) { return new ManageRegistrationResponse { IsModified = false } } ; var request = _mapper.Map <ManageRegistration>(reg); _mapper.Map(viewModel, request); var isSuccess = await _internalApiClient.UpdateRegistrationAsync(request); return(new ManageRegistrationResponse { ProfileId = request.ProfileId, Uln = request.Uln, IsModified = true, IsSuccess = isSuccess }); }