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

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContacts();

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

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContacts();

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

            IActionResult result = await sut.StartLoadingContacts();

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

            IActionResult result = await sut.StartLoadingContacts();

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

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContacts();

            ContactOptionsViewModel contactOptionsViewModel = (ContactOptionsViewModel)result.Model;

            Assert.That(contactOptionsViewModel.Countries, Is.Null);
        }
        public async Task StartLoadingContacts_WhenTokenWasReturnedFromTokenHelperFactoryAndExternalIdentifierIsWhiteSpace_ReturnsPartialViewResultWhereModelIsContactOptionsViewModelWhereExternalIdentifierIsNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContacts(externalIdentifier : " ");

            ContactOptionsViewModel contactOptionsViewModel = (ContactOptionsViewModel)result.Model;

            Assert.That(contactOptionsViewModel.ExternalIdentifier, Is.Null);
        }
        public async Task StartLoadingContacts_WhenTokenWasReturnedFromTokenHelperFactoryAndFilterIsEmpty_ReturnsPartialViewResultWhereModelIsContactOptionsViewModelWhereFilterIsNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContacts(string.Empty);

            ContactOptionsViewModel contactOptionsViewModel = (ContactOptionsViewModel)result.Model;

            Assert.That(contactOptionsViewModel.Filter, Is.Null);
        }
        public async Task StartLoadingContacts_WhenCalled_AssertGetTokenAsyncWasCalledOnTokenHelperFactory()
        {
            Controller sut = CreateSut();

            await sut.StartLoadingContacts();

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

            string            externalIdentifier = _fixture.Create <string>();
            PartialViewResult result             = (PartialViewResult)await sut.StartLoadingContacts(externalIdentifier : externalIdentifier);

            ContactOptionsViewModel contactOptionsViewModel = (ContactOptionsViewModel)result.Model;

            Assert.That(contactOptionsViewModel.ExternalIdentifier, Is.EqualTo(externalIdentifier));
        }