Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
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)));
        }
Exemple #4
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)));
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
0
        public async Task Index_WhenUserIsAuthenticatedWithAccessToAccountingsAndAccountingNumberWasReturnedFromClaimResolver_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithAccountingNumberEqualToAccountingNumberFromClaimResolver()
        {
            ClaimsPrincipal claimsPrincipal  = CreateClaimsPrincipal(hasAccountingClaimType: true);
            int             accountingNumber = _fixture.Create <int>();
            Controller      sut = CreateSut(claimsPrincipal, hasAccountingNumber: true, accountingNumber: accountingNumber);

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

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.AccountingNumber, Is.EqualTo(accountingNumber));
        }
Exemple #8
0
        public async Task Index_WhenUserIsAuthenticatedWithAccessToContactsAndMicrosoftGraphTokenWhichWillExpireWasReturnedFromTokenHelperFactory_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithUpcomingBirthdaysWithinDaysEqualToDefaultValue()
        {
            Mock <IRefreshableToken> refreshableTokenMock = _fixture.BuildRefreshableTokenMock(willExpireWithin: true);
            ClaimsPrincipal          claimsPrincipal      = CreateClaimsPrincipal(hasContactsClaimType: true);
            Controller sut = CreateSut(claimsPrincipal, true, refreshableTokenMock.Object);

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

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.UpcomingBirthdaysWithinDays, Is.EqualTo(default(int)));
        }
Exemple #9
0
        public async Task Index_WhenUserIsAuthenticatedWithAccessToContactsAndMicrosoftGraphTokenWhichWillNotExpireWasReturnedFromTokenHelperFactory_ReturnsViewResultWhereModelIsHomeOperationsViewModelWithHasAcquiredMicrosoftGraphTokenEqualToTrue()
        {
            Mock <IRefreshableToken> refreshableTokenMock = _fixture.BuildRefreshableTokenMock();
            ClaimsPrincipal          claimsPrincipal      = CreateClaimsPrincipal(hasContactsClaimType: true);
            Controller sut = CreateSut(claimsPrincipal, true, refreshableTokenMock.Object);

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

            HomeOperationsViewModel homeOperationsViewModel = (HomeOperationsViewModel)result.Model;

            Assert.That(homeOperationsViewModel.HasAcquiredMicrosoftGraphToken, Is.True);
        }