コード例 #1
0
            public void ReturnsAccessRestrictedWhenTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.AccessRestricted);
            }
コード例 #2
0
            public void ReturnsAccessRestrictedWhenTheTokenWasRevokedAndTheApiIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.AccessRestricted);
            }
コード例 #3
0
            public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                AppStart.Start();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                UserAccessManager.DidNotReceive().CheckIfLoggedIn();
            }
コード例 #4
0
ファイル: AppStartTests.cs プロジェクト: FinHorsley/mobileapp
            public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                AppStart.Start();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                UserAccessManager.DidNotReceive().TryInitializingAccessToUserData(out _, out _);
            }
コード例 #5
0
            public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated()
            {
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                await Task.Run(() => AppStart.Start());

                await NavigationService.Received().Navigate <OnboardingViewModel>();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                LoginManager.DidNotReceive().GetDataSourceIfLoggedIn();
            }
コード例 #6
0
            public async Task ShowsTheOutdatedViewIfTheTokenWasRevokedAndTheApiIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                AppStart.Start();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                await NavigationService.DidNotReceive().Navigate <TokenResetViewModel>();

                UserAccessManager.DidNotReceive().CheckIfLoggedIn();
            }
コード例 #7
0
            public async Task ShowsTheOutdatedViewIfTheTokenWasRevokedAndTheApiIsOutdated()
            {
                AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(true);

                await Task.Run(() => AppStart.Start());

                await NavigationService.Received().Navigate <OnboardingViewModel>();

                await NavigationService.Received().Navigate <OutdatedAppViewModel>();

                await NavigationService.DidNotReceive().Navigate <TokenResetViewModel>();

                LoginManager.DidNotReceive().GetDataSourceIfLoggedIn();
            }
コード例 #8
0
            public async Task DoesNotShowTheUnauthorizedAccessViewIfUsersApiTokenChanged()
            {
                var oldApiToken       = Guid.NewGuid().ToString();
                var newApiToken       = Guid.NewGuid().ToString();
                var user              = Substitute.For <IThreadSafeUser>();
                var interactorFactory = Substitute.For <IInteractorFactory>();

                user.ApiToken.Returns(newApiToken);
                interactorFactory.GetCurrentUser().Execute().Returns(Observable.Return(user));
                AccessRestrictionStorage.IsUnauthorized(Arg.Is(oldApiToken)).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(false);
                AccessRestrictionStorage.IsClientOutdated().Returns(false);

                AppStart.Start();

                await NavigationService.Received().Navigate <MainTabBarViewModel>();
            }
コード例 #9
0
            public void ReturnsLoggedInWhenUsersApiTokenChanged()
            {
                var oldApiToken       = Guid.NewGuid().ToString();
                var newApiToken       = Guid.NewGuid().ToString();
                var user              = Substitute.For <IThreadSafeUser>();
                var interactorFactory = Substitute.For <IInteractorFactory>();

                user.ApiToken.Returns(newApiToken);
                interactorFactory.GetCurrentUser().Execute().Returns(Observable.Return(user));
                AccessRestrictionStorage.IsUnauthorized(Arg.Is(oldApiToken)).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(false);
                AccessRestrictionStorage.IsClientOutdated().Returns(false);

                var accessLevel = App.GetAccessLevel();

                accessLevel.Should().Be(AccessLevel.LoggedIn);
            }
コード例 #10
0
            public async Task DoesNotShowTheUnauthorizedAccessViewIfUsersApiTokenChanged()
            {
                var oldApiToken = Guid.NewGuid().ToString();
                var newApiToken = Guid.NewGuid().ToString();
                var user        = Substitute.For <IThreadSafeUser>();
                var dataSource  = Substitute.For <ITogglDataSource>();
                var userSource  = Substitute.For <IUserSource>();

                user.ApiToken.Returns(newApiToken);
                userSource.Current.Returns(Observable.Return(user));
                dataSource.User.Returns(userSource);
                LoginManager.GetDataSourceIfLoggedIn().Returns(dataSource);
                AccessRestrictionStorage.IsUnauthorized(Arg.Is(oldApiToken)).Returns(true);
                AccessRestrictionStorage.IsApiOutdated().Returns(false);
                AccessRestrictionStorage.IsClientOutdated().Returns(false);

                await Task.Run(() => AppStart.Start());

                await NavigationService.Received().Navigate <MainTabBarViewModel>();
            }