コード例 #1
0
        public ICountry ApplyLogicForPrincipal(ICountry country)
        {
            NullGuard.NotNull(country, nameof(country));

            string countryCode = _claimResolver.GetCountryCode();

            country.ApplyDefaultForPrincipal(countryCode);

            return(country);
        }
コード例 #2
0
        public void GetCountryCode_WhenCalled_AssertGetCurrentPrincipalWasCalledOnPrincipalResolver()
        {
            IClaimResolver sut = CreateSut();

            sut.GetCountryCode();

            _principalResolverMock.Verify(m => m.GetCurrentPrincipal(), Times.Once);
        }
コード例 #3
0
        public void GetCountryCode_WhenCalledAndPrincipalDoesNotHaveCountryCodeClaim_ReturnsNull()
        {
            IPrincipal     principal = CreateClaimsPrincipal(new[] { new Claim(_fixture.Create <string>(), _fixture.Create <string>()) });
            IClaimResolver sut       = CreateSut(principal);

            string result = sut.GetCountryCode();

            Assert.That(result, Is.Null);
        }
コード例 #4
0
        public void GetCountryCode_WhenCalledAndPrincipalHasCountryCodeClaim_ReturnsCountryCode()
        {
            string         countryCode = _fixture.Create <string>();
            IPrincipal     principal   = CreateClaimsPrincipal(new[] { new Claim(_fixture.Create <string>(), _fixture.Create <string>()), ClaimHelper.CreateCountryCodeClaim(countryCode) });
            IClaimResolver sut         = CreateSut(principal);

            string result = sut.GetCountryCode();

            Assert.That(result, Is.EqualTo(countryCode));
        }
コード例 #5
0
        public async Task <IActionResult> Contacts(string filter = null, string externalIdentifier = null)
        {
            string defaultCountryCode = _claimResolver.GetCountryCode();

            IEnumerable <CountryViewModel> countryViewModels = await GetCountryViewModels();

            ContactOptionsViewModel contactOptionsViewModel = new ContactOptionsViewModel
            {
                Filter             = string.IsNullOrWhiteSpace(filter) ? null : filter,
                ExternalIdentifier = string.IsNullOrWhiteSpace(externalIdentifier) ? null : externalIdentifier,
                DefaultCountryCode = defaultCountryCode,
                Countries          = countryViewModels?.ToList() ?? new List <CountryViewModel>(0)
            };

            return(View("Contacts", contactOptionsViewModel));
        }