public void MarksTheUserAsNotNewWhenUsingTheAppForTheFirstTimeAfterSixtyDays() { var now = DateTimeOffset.Now; TimeService.CurrentDateTime.Returns(now); OnboardingStorage.GetLastOpened().Returns(now.AddDays(-60)); var dependencyContainer = new TestDependencyContainer { MockTimeService = TimeService, MockUserAccessManager = UserAccessManager, MockNavigationService = NavigationService, MockOnboardingStorage = OnboardingStorage, MockAccessRestrictionStorage = AccessRestrictionStorage, MockSyncManager = Substitute.For <ISyncManager>(), MockInteractorFactory = Substitute.For <IInteractorFactory>(), MockBackgroundSyncService = Substitute.For <IBackgroundSyncService>() }; var app = new AppStart(dependencyContainer); app.UpdateOnboardingProgress(); OnboardingStorage.Received().SetLastOpened(now); OnboardingStorage.Received().SetIsNewUser(false); }
private static TestConfigurator configureTogglSyncGraph() { var configurator = new TestConfigurator(); var entryPoints = new StateMachineEntryPoints(); var dependencyContainer = new TestDependencyContainer(); dependencyContainer.MockKeyValueStorage = Substitute.For <IKeyValueStorage>(); dependencyContainer.MockPushNotificationsTokenService = Substitute.For <IPushNotificationsTokenService>(); dependencyContainer.MockTimeService = Substitute.For <ITimeService>(); dependencyContainer.MockRemoteConfigService = Substitute.For <IRemoteConfigService>(); dependencyContainer.MockPushNotificationsTokenStorage = Substitute.For <IPushNotificationsTokenStorage>(); configurator.AllDistinctStatesInOrder.Add(entryPoints); TogglSyncManager.ConfigureTransitions( configurator, Substitute.For <ITogglDatabase>(), Substitute.For <ITogglApi>(), Substitute.For <ITogglDataSource>(), Substitute.For <IScheduler>(), Substitute.For <ITimeService>(), Substitute.For <IAnalyticsService>(), Substitute.For <ILastTimeUsageStorage>(), entryPoints, Substitute.For <ISyncStateQueue>(), dependencyContainer ); return(configurator); }
private TestDependencyContainer createContainer() { var container = new TestDependencyContainer { MockUserAccessManager = Substitute.For <IUserAccessManager>(), MockAccessRestrictionStorage = Substitute.For <IAccessRestrictionStorage>(), MockAnalyticsService = Substitute.For <IAnalyticsService>(), MockBackgroundSyncService = Substitute.For <IBackgroundSyncService>(), MockCalendarService = Substitute.For <ICalendarService>(), MockDatabase = Substitute.For <ITogglDatabase>(), MockDataSource = Substitute.For <ITogglDataSource>(), MockKeyValueStorage = Substitute.For <IKeyValueStorage>(), MockLastTimeUsageStorage = Substitute.For <ILastTimeUsageStorage>(), MockLicenseProvider = Substitute.For <ILicenseProvider>(), MockNavigationService = Substitute.For <INavigationService>(), MockNotificationService = Substitute.For <INotificationService>(), MockAccessibilityService = Substitute.For <IAccessibilityService>(), MockOnboardingStorage = Substitute.For <IOnboardingStorage>(), MockPermissionsChecker = Substitute.For <IPermissionsChecker>(), MockPlatformInfo = Substitute.For <IPlatformInfo>(), MockPrivateSharedStorageService = Substitute.For <IPrivateSharedStorageService>(), MockRatingService = Substitute.For <IRatingService>(), MockRemoteConfigService = Substitute.For <IRemoteConfigService>(), MockSchedulerProvider = Substitute.For <ISchedulerProvider>(), MockShortcutCreator = Substitute.For <IApplicationShortcutCreator>(), MockUserPreferences = Substitute.For <IUserPreferences>(), MockInteractorFactory = Substitute.For <IInteractorFactory>(), MockTimeService = Substitute.For <ITimeService>(), MockSyncManager = Substitute.For <ISyncManager>(), }; container.MockLicenseProvider.GetAppLicenses().Returns(new Dictionary <string, string>()); return(container); }
protected override void AdditionalSetup() { var container = new TestDependencyContainer { MockSyncManager = SyncManager }; TestDependencyContainer.Initialize(container); }
protected override void AdditionalSetup() { Location.CountryCode.Returns("LV"); Location.CountryName.Returns("Latvia"); Api.Location.Get().ReturnsTaskOf(Location); ApiFactory.CreateApiWith(Arg.Any <Credentials>()).Returns(Api); var container = new TestDependencyContainer { MockSyncManager = SyncManager }; TestDependencyContainer.Initialize(container); }
public void SetsFirstOpenedTime() { TimeService.CurrentDateTime.Returns(new DateTimeOffset(2020, 1, 2, 3, 4, 5, TimeSpan.Zero)); var dependencyContainer = new TestDependencyContainer { MockTimeService = TimeService, MockUserAccessManager = UserAccessManager, MockNavigationService = NavigationService, MockOnboardingStorage = OnboardingStorage, MockAccessRestrictionStorage = AccessRestrictionStorage, MockSyncManager = Substitute.For <ISyncManager>(), MockInteractorFactory = Substitute.For <IInteractorFactory>(), MockBackgroundSyncService = Substitute.For <IBackgroundSyncService>() }; var appStart = new AppStart(dependencyContainer); appStart.SetFirstOpened(); OnboardingStorage.Received().SetFirstOpened(TimeService.CurrentDateTime); }
protected AppStartTest() { var api = Substitute.For <ITogglApi>(); UserAccessManager.UserLoggedIn.Returns(Observable.Return(api)); var dependencyContainer = new TestDependencyContainer { MockTimeService = TimeService, MockUserAccessManager = UserAccessManager, MockNavigationService = NavigationService, MockOnboardingStorage = OnboardingStorage, MockAccessRestrictionStorage = AccessRestrictionStorage, MockSyncManager = Substitute.For <ISyncManager>(), MockInteractorFactory = Substitute.For <IInteractorFactory>(), MockBackgroundSyncService = Substitute.For <IBackgroundSyncService>() }; UserAccessManager.CheckIfLoggedIn().Returns(true); AppStart = new AppStart <OnboardingViewModel>(App, dependencyContainer); }
public AppServices(ITogglApi api, ITogglDatabase database) { TogglApi = api; Scheduler = System.Reactive.Concurrency.Scheduler.Default; TimeService = new TimeService(Scheduler); var errorHandlingService = new ErrorHandlingService(NavigationServiceSubstitute, AccessRestrictionStorageSubsitute); syncErrorHandlingService = new SyncErrorHandlingService(errorHandlingService); var dataSource = new TogglDataSource( database, TimeService, AnalyticsServiceSubstitute); var dependencyContainer = new TestDependencyContainer(); dependencyContainer.MockKeyValueStorage = KeyValueStorage; dependencyContainer.MockPushNotificationsTokenService = PushNotificationsTokenService; dependencyContainer.MockTimeService = TimeService; dependencyContainer.MockPushNotificationsTokenStorage = PushNotificationsTokenStorage; dependencyContainer.MockRemoteConfigService = RemoteConfigService; SyncManager = TogglSyncManager.CreateSyncManager( database, api, dataSource, TimeService, AnalyticsServiceSubstitute, LastTimeUsageStorageSubstitute, Scheduler, AutomaticSyncingService, dependencyContainer); syncErrorHandlingService.HandleErrorsOf(SyncManager); }