public ICountry ApplyLogicForPrincipal(ICountry country) { NullGuard.NotNull(country, nameof(country)); string countryCode = _claimResolver.GetCountryCode(); country.ApplyDefaultForPrincipal(countryCode); return(country); }
public void GetCountryCode_WhenCalled_AssertGetCurrentPrincipalWasCalledOnPrincipalResolver() { IClaimResolver sut = CreateSut(); sut.GetCountryCode(); _principalResolverMock.Verify(m => m.GetCurrentPrincipal(), Times.Once); }
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); }
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)); }
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)); }