public async Task StartLoadingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereModelIsContactIdentificationViewModel()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContact(_fixture.Create <string>(), _fixture.Create <string>());

            Assert.That(result.Model, Is.TypeOf <ContactIdentificationViewModel>());
        }
        public async Task StartLoadingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereViewNameIsEqualToLoadingContactPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContact(_fixture.Create <string>(), _fixture.Create <string>());

            Assert.That(result.ViewName, Is.EqualTo("_LoadingContactPartial"));
        }
        public async Task StartLoadingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.StartLoadingContact(_fixture.Create <string>(), _fixture.Create <string>());

            Assert.That(result, Is.TypeOf <PartialViewResult>());
        }
        public async Task StartLoadingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultViewDataContainsCountryCode()
        {
            Controller sut = CreateSut();

            string            countryCode = _fixture.Create <string>();
            PartialViewResult result      = (PartialViewResult)await sut.StartLoadingContact(_fixture.Create <string>(), countryCode);

            Assert.That(result.ViewData.ContainsKey("CountryCode"), Is.True);
            Assert.That(result.ViewData["CountryCode"], Is.EqualTo(countryCode));
        }
        public async Task StartLoadingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereModelIsContactIdentificationViewModelWhereContactTypeIsUnknown()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContact(_fixture.Create <string>(), _fixture.Create <string>());

            ContactIdentificationViewModel contactIdentificationViewModel = (ContactIdentificationViewModel)result.Model;

            Assert.That(contactIdentificationViewModel.ContactType, Is.EqualTo(ContactType.Unknown));
        }
        public async Task StartLoadingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereModelIsContactIdentificationViewModelWhereDisplayNameIsNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContact(_fixture.Create <string>(), _fixture.Create <string>());

            ContactIdentificationViewModel contactIdentificationViewModel = (ContactIdentificationViewModel)result.Model;

            Assert.That(contactIdentificationViewModel.DisplayName, Is.Null);
        }
        public async Task StartLoadingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereModelIsContactIdentificationViewModelWhereExternalIdentifierIsEqualToInput()
        {
            Controller sut = CreateSut();

            string            externalIdentifier = _fixture.Create <string>();
            PartialViewResult result             = (PartialViewResult)await sut.StartLoadingContact(externalIdentifier, _fixture.Create <string>());

            ContactIdentificationViewModel contactIdentificationViewModel = (ContactIdentificationViewModel)result.Model;

            Assert.That(contactIdentificationViewModel.ExternalIdentifier, Is.EqualTo(externalIdentifier));
        }
        public async Task StartLoadingContact_WhenCalledWithExternalIdentifierAndCountryCode_AssertGetTokenAsyncWasCalledOnTokenHelperFactory()
        {
            Controller sut = CreateSut();

            await sut.StartLoadingContact(_fixture.Create <string>(), _fixture.Create <string>());

            _tokenHelperFactoryMock.Verify(m => m.GetTokenAsync <IRefreshableToken>(
                                               It.Is <TokenType>(value => value == TokenType.MicrosoftGraphToken),
                                               It.IsAny <HttpContext>()),
                                           Times.Once);
        }
        public void StartLoadingContact_WhenCountryCodeIsWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.StartLoadingContact(_fixture.Create <string>(), " "));

            Assert.That(result.ParamName, Is.EqualTo("countryCode"));
        }
        public void StartLoadingContact_WhenExternalIdentifierIsWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.StartLoadingContact(" ", _fixture.Create <string>()));

            Assert.That(result.ParamName, Is.EqualTo("externalIdentifier"));
        }