public void ReturnsAccessRestrictedWhenTheVersionOfTheCurrentlyUsedApiIsOutdated() { AccessRestrictionStorage.IsApiOutdated().Returns(true); var accessLevel = App.GetAccessLevel(); accessLevel.Should().Be(AccessLevel.AccessRestricted); }
public void ReturnsAccessRestrictedWhenTheTokenWasRevokedAndTheApiIsOutdated() { AccessRestrictionStorage.IsUnauthorized(Arg.Any <string>()).Returns(true); AccessRestrictionStorage.IsApiOutdated().Returns(true); var accessLevel = App.GetAccessLevel(); accessLevel.Should().Be(AccessLevel.AccessRestricted); }
public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated() { AccessRestrictionStorage.IsApiOutdated().Returns(true); AppStart.Start(); await NavigationService.Received().Navigate <OutdatedAppViewModel>(); UserAccessManager.DidNotReceive().CheckIfLoggedIn(); }
public async Task ShowsTheOutdatedViewIfTheVersionOfTheCurrentlyUsedApiIsOutdated() { AccessRestrictionStorage.IsApiOutdated().Returns(true); AppStart.Start(); await NavigationService.Received().Navigate <OutdatedAppViewModel>(); UserAccessManager.DidNotReceive().TryInitializingAccessToUserData(out _, out _); }
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(); }
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(); }
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(); }
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>(); }
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); }
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>(); }