Exemple #1
0
        public override void Given()
        {
            _postcodeViewModel = new AddAddressPostcodeViewModel {
                Postcode = "xx1 1yy"
            };

            _cacheResult = new AddAddressViewModel
            {
                AddAddressPostcode = _postcodeViewModel
            };

            _addressesMockResult = new AddAddressSelectViewModel
            {
                AddressSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Hello", Value = "236547891"
                    }
                }
            };

            ViewModel = new AddAddressSelectViewModel
            {
                Postcode = _cacheResult.AddAddressPostcode.Postcode
            };

            CacheService.GetAsync <AddAddressViewModel>(CacheKey).Returns(_cacheResult);
            ProviderAddressLoader.GetAddressesByPostcodeAsync(_postcodeViewModel.Postcode).Returns(_addressesMockResult);
            Controller.ModelState.AddModelError(nameof(AddAddressSelectViewModel.SelectedAddressUprn), AddAddressContent.AddAddressSelect.Validation_Select_Your_Address_From_The_List);
        }
Exemple #2
0
        public override void Given()
        {
            _postcodeViewModel = new AddAddressPostcodeViewModel {
                Postcode = "xx1 1yy"
            };
            _addressSelectViewModel = new AddAddressSelectViewModel
            {
                SelectedAddressUprn = 236547891,
                DepartmentName      = "Test Dept Name",
                Postcode            = _postcodeViewModel.Postcode
            };

            _cacheResult = new AddAddressViewModel
            {
                AddAddressPostcode = _postcodeViewModel,
                AddAddressSelect   = _addressSelectViewModel
            };

            _addressesMockResult = new AddAddressSelectViewModel
            {
                AddressSelectList = new List <SelectListItem> {
                    new SelectListItem {
                        Text = "Hello", Value = "236547891"
                    }
                }
            };

            CacheService.GetAsync <AddAddressViewModel>(CacheKey).Returns(_cacheResult);
            ProviderAddressLoader.GetAddressesByPostcodeAsync(_postcodeViewModel.Postcode).Returns(_addressesMockResult);
        }
        public override void Given()
        {
            _uprn = 236547891;
            _postcodeViewModel = new AddAddressPostcodeViewModel {
                Postcode = "xx1 1yy"
            };

            _cacheResult = new AddAddressViewModel
            {
                AddAddressPostcode = _postcodeViewModel
            };

            _addressViewModel = new AddressViewModel
            {
                Udprn            = _uprn.ToString(),
                FormattedAddress = "5, Test road, Test town, xx1 1yy",
                DepartmentName   = "Dept name",
                OrganisationName = "Org name",
                AddressLine1     = "5",
                AddressLine2     = "Test road",
                Town             = "Test town",
                Postcode         = "xx1 1yy"
            };

            ViewModel = new AddAddressSelectViewModel
            {
                Postcode            = _cacheResult.AddAddressPostcode.Postcode,
                SelectedAddressUprn = _uprn
            };

            CacheService.GetAsync <AddAddressViewModel>(CacheKey).Returns(_cacheResult);
            ProviderAddressLoader.GetAddressByUprnAsync(ViewModel.SelectedAddressUprn.Value).Returns(_addressViewModel);
        }
Exemple #4
0
 public override void Given()
 {
     _cachePostcodeViewModel = new AddAddressPostcodeViewModel {
         Postcode = "AB1 2CD"
     };
     _cacheResult = new AddAddressViewModel {
         AddAddressPostcode = _cachePostcodeViewModel
     };
     CacheService.GetAsync <AddAddressViewModel>(CacheKey).Returns(_cacheResult);
 }
Exemple #5
0
        public async Task <IActionResult> AddAddressPostcodeAsync(bool showPostcode = true, bool isFromAddressMissing = false)
        {
            var cacheModel = await _cacheService.GetAsync <AddAddressViewModel>(CacheKey);

            var viewModel = new AddAddressPostcodeViewModel
            {
                Postcode             = showPostcode && cacheModel?.AddAddressPostcode != null ? cacheModel.AddAddressPostcode.Postcode : null,
                IsFromAddressMissing = (bool)(cacheModel?.AddAddressPostcode != null ? cacheModel?.AddAddressPostcode.IsFromAddressMissing : isFromAddressMissing)
            };

            return(View(viewModel));
        }
        public override void Given()
        {
            ShowPostcode       = true;
            _postcodeViewModel = new AddAddressPostcodeViewModel {
                Postcode = "xx1 1yy", IsFromAddressMissing = true
            };
            _cacheResult = new AddAddressViewModel
            {
                AddAddressPostcode = _postcodeViewModel
            };

            CacheService.GetAsync <AddAddressViewModel>(CacheKey).Returns(_cacheResult);
        }
Exemple #7
0
        public async Task <IActionResult> AddAddressPostcodeAsync(AddAddressPostcodeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var cacheModel = new AddAddressViewModel {
                AddAddressPostcode = model
            };
            await _cacheService.SetAsync(CacheKey, cacheModel);

            return(RedirectToRoute(RouteConstants.AddAddressSelect));
        }
Exemple #8
0
        public override void Given()
        {
            AddAddressPostcode = new AddAddressPostcodeViewModel {
                Postcode = "xx1 1yy"
            };
            AddAddressSelect = new AddAddressSelectViewModel {
                SelectedAddressUprn = 123456789, SelectedAddress = new AddressViewModel {
                    OrganisationName = "Org name", AddressLine1 = "Line1", AddressLine2 = "Line2", Town = "town", Postcode = "xx1 1yy"
                }
            };

            AddAddressViewModel = new AddAddressViewModel
            {
                AddAddressPostcode = AddAddressPostcode,
                AddAddressSelect   = AddAddressSelect
            };

            CacheService.GetAsync <AddAddressViewModel>(CacheKey).Returns(AddAddressViewModel);
            ProviderAddressLoader.AddAddressAsync(ProviderUkprn, AddAddressViewModel).Returns(false);
        }
        public override void Given()
        {
            _uprn = 236547891;
            _postcodeViewModel = new AddAddressPostcodeViewModel {
                Postcode = "xx1 1yy"
            };

            _cacheResult = new AddAddressViewModel
            {
                AddAddressPostcode = _postcodeViewModel
            };

            _addressViewModel = null;

            ViewModel = new AddAddressSelectViewModel
            {
                Postcode            = _cacheResult.AddAddressPostcode.Postcode,
                SelectedAddressUprn = _uprn
            };

            CacheService.GetAsync <AddAddressViewModel>(CacheKey).Returns(_cacheResult);
            ProviderAddressLoader.GetAddressByUprnAsync(ViewModel.SelectedAddressUprn.Value).Returns(_addressViewModel);
        }
 public override void Given()
 {
     ViewModel = new AddAddressPostcodeViewModel {
         Postcode = "AB1 2CD"
     };
 }
 public override void Given()
 {
     ViewModel = new AddAddressPostcodeViewModel();
     Controller.ModelState.AddModelError(nameof(AddAddressPostcodeViewModel.Postcode), AddAddressContent.AddAddressPostcode.Validation_Enter_Postcode);
 }