public async Task UpcomingBirthdays_WhenNoTokenWasReturnedFromTokenHelperFactory_AssertQueryAsyncWasNotCalledOnQueryBus()
        {
            Controller sut = CreateSut(false);

            await sut.UpcomingBirthdays(_fixture.Create <int>());

            _queryBusMock.Verify(m => m.QueryAsync <IGetContactWithBirthdayCollectionQuery, IEnumerable <IContact> >(It.IsAny <IGetContactWithBirthdayCollectionQuery>()), Times.Never);
        }
        public async Task AccountingInformation_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereViewNameIsEqualToAccountingPresentationPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AccountingInformation(_fixture.Create <int>());

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

            IActionResult result = await sut.UpcomingBirthdays(_fixture.Create <int>());

            Assert.That(result, Is.TypeOf <UnauthorizedResult>());
        }
Beispiel #4
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResultWhereFileContentsIsNotEmpty()
        {
            Controller sut = CreateSut();

            FileContentResult result = (FileContentResult)sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(result.FileContents, Is.Not.Empty);
        }
Beispiel #5
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResult()
        {
            Controller sut = CreateSut();

            IActionResult result = sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(result, Is.TypeOf <FileContentResult>());
        }
Beispiel #6
0
        public void AcmeChallenge_WhenChallengeTokenIsWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.AcmeChallenge(" "));

            Assert.That(result.ParamName, Is.EqualTo("challengeToken"));
        }
        public async Task AccountingInformation_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AccountingInformation(_fixture.Create <int>());

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

            IActionResult result = await sut.AccountingInformation(_fixture.Create <int>());

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

            IActionResult result = await sut.UpcomingBirthdays(_fixture.Create <int>());

            Assert.That(result, Is.TypeOf <PartialViewResult>());
        }
Beispiel #10
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResultWhereContentTypeIsEqualToApplicationOctetStream()
        {
            Controller sut = CreateSut();

            FileContentResult result = (FileContentResult)sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(result.ContentType, Is.EqualTo("application/octet-stream"));
        }
        public async Task UpcomingBirthdays_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereViewNameIsEqualToUpcomingBirthdayCollectionPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.UpcomingBirthdays(_fixture.Create <int>());

            Assert.That(result.ViewName, Is.EqualTo("_UpcomingBirthdayCollectionPartial"));
        }
Beispiel #12
0
        public async Task Index_WhenUserIsAuthenticated_ReturnsViewResultWhereModelIsHomeOperationsViewModel()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)await sut.Index();

            Assert.That(result.Model, Is.TypeOf <HomeOperationsViewModel>());
        }
Beispiel #13
0
        public async Task Index_WhenUserIsAuthenticated_ReturnsViewResultWhereViewNameIsEqualToIndex()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)await sut.Index();

            Assert.That(result.ViewName, Is.EqualTo("Index"));
        }
Beispiel #14
0
        public async Task Index_WhenUserIsAuthenticated_ReturnsViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.Index();

            Assert.That(result, Is.TypeOf <ViewResult>());
        }
Beispiel #15
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResultWhereFileContentsIsEqualToConstructedKeyAuthorization()
        {
            string     constructedKeyAuthorization = _fixture.Create <string>();
            Controller sut = CreateSut(constructedKeyAuthorization: constructedKeyAuthorization);

            FileContentResult result = (FileContentResult)sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(Encoding.UTF8.GetString(result.FileContents), Is.EqualTo(constructedKeyAuthorization));
        }
Beispiel #16
0
        public async Task Index_WhenUserIsNotAuthenticated_ReturnsViewResult()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(false);
            Controller      sut             = CreateSut(claimsPrincipal);

            IActionResult result = await sut.Index();

            Assert.That(result, Is.TypeOf <ViewResult>());
        }
Beispiel #17
0
        public async Task Index_WhenUserIsNotAuthenticated_AssertGetAccountingNumberWasNotCalledOnClaimResolver()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(false);
            Controller      sut             = CreateSut(claimsPrincipal);

            await sut.Index();

            _claimResolverMock.Verify(m => m.GetAccountingNumber(), Times.Never);
        }
Beispiel #18
0
        public async Task Index_WhenUserIsAuthenticatedWithAccessToAccountings_AssertGetAccountingNumberWasCalledOnClaimResolver()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(hasAccountingClaimType: true);
            Controller      sut             = CreateSut(claimsPrincipal);

            await sut.Index();

            _claimResolverMock.Verify(m => m.GetAccountingNumber(), Times.Once);
        }
Beispiel #19
0
        public async Task Index_WhenUserIsNotAuthenticated_ReturnsViewResultWhereViewNameIsEqualToIndex()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(false);
            Controller      sut             = CreateSut(claimsPrincipal);

            ViewResult result = (ViewResult)await sut.Index();

            Assert.That(result.ViewName, Is.EqualTo("Index"));
        }
Beispiel #20
0
        public async Task Index_WhenUserIsNotAuthenticated_ReturnsViewResultWhereModelIsHomeOperationsViewModel()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(false);
            Controller      sut             = CreateSut(claimsPrincipal);

            ViewResult result = (ViewResult)await sut.Index();

            Assert.That(result.Model, Is.TypeOf <HomeOperationsViewModel>());
        }
Beispiel #21
0
        public async Task Index_WhenUserIsAuthenticatedWithAccessToContactsAndMicrosoftGraphTokenWasReturnedFromTokenHelperFactory_AssertWillExpireWithinWasCalledOnMicrosoftGraphTokenFromTokenHelperFactory()
        {
            Mock <IRefreshableToken> refreshableTokenMock = _fixture.BuildRefreshableTokenMock();
            ClaimsPrincipal          claimsPrincipal      = CreateClaimsPrincipal(hasContactsClaimType: true);
            Controller sut = CreateSut(claimsPrincipal, true, refreshableTokenMock.Object);

            await sut.Index();

            refreshableTokenMock.Verify(m => m.WillExpireWithin(It.Is <TimeSpan>(value => value.Days == 0 && value.Hours == 0 && value.Minutes == 1 && value.Seconds == 0 && value.Milliseconds == 0)), Times.Once);
        }
Beispiel #22
0
        public void AcmeChallenge_WhenChallengeTokenIsNotNullEmptyOrWhiteSpace_AssertGetConstructedKeyAuthorizationWasCalledOnAcmeChallengeResolver()
        {
            Controller sut = CreateSut();

            string challengeToken = _fixture.Create <string>();

            sut.AcmeChallenge(challengeToken);

            _acmeChallengeResolverMock.Verify(m => m.GetConstructedKeyAuthorization(It.Is <string>(value => string.IsNullOrWhiteSpace(value) == false && string.CompareOrdinal(value, challengeToken) == 0)), Times.Once);
        }
        public async Task UpcomingBirthdays_WhenCalled_AssertGetTokenAsyncWasCalledOnTokenHelperFactory()
        {
            Controller sut = CreateSut();

            await sut.UpcomingBirthdays(_fixture.Create <int>());

            _tokenHelperFactoryMock.Verify(m => m.GetTokenAsync <IRefreshableToken>(
                                               It.Is <TokenType>(value => value == TokenType.MicrosoftGraphToken),
                                               It.IsAny <HttpContext>()),
                                           Times.Once);
        }
Beispiel #24
0
        public async Task Index_WhenUserIsAuthenticatedWithAccessToContacts_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithCanAccessContactsEqualToTrue()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(hasContactsClaimType: true);
            Controller      sut             = CreateSut(claimsPrincipal);

            ViewResult result = (ViewResult)await sut.Index();

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.CanAccessContacts, Is.True);
        }
Beispiel #25
0
        public async Task Index_WhenUserIsAuthenticatedWithAccessToContactsAndNoMicrosoftGraphTokenWasReturnedFromTokenHelperFactory_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithinDaysEqualToDefaultValue()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(hasContactsClaimType: true);
            Controller      sut             = CreateSut(claimsPrincipal, false);

            ViewResult result = (ViewResult)await sut.Index();

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.UpcomingBirthdaysWithinDays, Is.EqualTo(default(int)));
        }
Beispiel #26
0
        public async Task Index_WhenUserIsAuthenticatedWithoutAccessToContacts_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithHasAcquiredMicrosoftGraphTokenEqualToFalse()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(hasContactsClaimType: false);
            Controller      sut             = CreateSut(claimsPrincipal);

            ViewResult result = (ViewResult)await sut.Index();

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.HasAcquiredMicrosoftGraphToken, Is.False);
        }
Beispiel #27
0
        public async Task Index_WhenUserIsAuthenticatedWithoutAccessToContacts_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithUpcomingBirthdaysWithinDaysEqualToDefaultValue()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(hasContactsClaimType: false);
            Controller      sut             = CreateSut(claimsPrincipal);

            ViewResult result = (ViewResult)await sut.Index();

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.UpcomingBirthdaysWithinDays, Is.EqualTo(default(int)));
        }
Beispiel #28
0
        public async Task Index_WhenUserIsAuthenticatedWithoutAccessToAccountings_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithAccountingNumberEqualToNull()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(hasAccountingClaimType: false);
            Controller      sut             = CreateSut(claimsPrincipal);

            ViewResult result = (ViewResult)await sut.Index();

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.AccountingNumber, Is.Null);
        }
Beispiel #29
0
        public async Task Index_WhenUserIsNotAuthenticated_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithCanAccessAccountingsEqualToFalse()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(false);
            Controller      sut             = CreateSut(claimsPrincipal);

            ViewResult result = (ViewResult)await sut.Index();

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.CanAccessAccountings, Is.False);
        }
Beispiel #30
0
        public async Task Index_WhenUserIsNotAuthenticated_AssertGetTokenAsyncWasNotCalledOnTokenHelperFactoryForMicrosoftGraphToken()
        {
            ClaimsPrincipal claimsPrincipal = CreateClaimsPrincipal(false);
            Controller      sut             = CreateSut(claimsPrincipal);

            await sut.Index();

            _tokenHelperFactoryMock.Verify(m => m.GetTokenAsync <IRefreshableToken>(
                                               It.Is <TokenType>(value => value == TokenType.MicrosoftGraphToken),
                                               It.IsAny <HttpContext>()),
                                           Times.Never);
        }