public void BuildingWorksIfAllParametersAreProvided() { var version = Version.Parse("1.0"); var scheduler = Substitute.For <IScheduler>(); var apiFactory = Substitute.For <IApiFactory>(); var agent = new UserAgent("Some Client", "1.0"); var database = Substitute.For <ITogglDatabase>(); var timeService = Substitute.For <ITimeService>(); var mailService = Substitute.For <IMailService>(); var googleService = Substitute.For <IGoogleService>(); var licenseProvider = Substitute.For <ILicenseProvider>(); var analyticsService = Substitute.For <IAnalyticsService>(); var platformConstants = Substitute.For <IPlatformConstants>(); var backgroundService = Substitute.For <IBackgroundService>(); var applicationShortcutCreator = Substitute.For <IApplicationShortcutCreator>(); var suggestionProviderContainer = Substitute.For <ISuggestionProviderContainer>(); Action tryingToConstructWithValidParameters = () => TogglFoundation .ForClient(agent, version) .WithDatabase(database) .WithScheduler(scheduler) .WithApiFactory(apiFactory) .WithTimeService(timeService) .WithMailService(mailService) .WithGoogleService(googleService) .WithLicenseProvider(licenseProvider) .WithAnalyticsService(analyticsService) .WithBackgroundService(backgroundService) .WithPlatformConstants(platformConstants) .WithApplicationShortcutCreator(applicationShortcutCreator) .WithSuggestionProviderContainer(suggestionProviderContainer) .Build(); tryingToConstructWithValidParameters.Should().NotThrow(); }
private TogglFoundation constructFoundation() => TogglFoundation.ForClient(userAgent, version) .WithDatabase(database) .WithScheduler(scheduler) .WithApiFactory(apiFactory) .WithTimeService(timeService) .WithPlatformInfo(platformInfo) .WithRatingService(ratingService) .WithGoogleService(googleService) .WithLicenseProvider(licenseProvider) .WithAnalyticsService(analyticsService) .WithStopwatchProvider(stopwatchProvider) .WithBackgroundService(backgroundService) .WithBackgroundSyncService(backgroundSyncService) .WithSchedulerProvider(schedulerProvider) .WithPlatformInfo(platformInfo) .WithNotificationService(notificationService) .WithRemoteConfigService(remoteConfigService) .WithIntentDonationService(IntentDonationService) .WithApplicationShortcutCreator(applicationShortcutCreator) .WithSuggestionProviderContainer(suggestionProviderContainer) .WithPrivateSharedStorageService(PrivateSharedStorageService) .WithAutomaticSyncingService(automaticSyncingService) .Build();
public void ThrowsIfAnyOfTheArgumentsIsNull( bool userAgent, bool useVersion, bool useDatabase, bool useScheduler, bool useApiFactory, bool useTimeService, bool usePlatformInfo, bool useRatingService, bool useGoogleService, bool useLicenseProvider, bool useAnalyticsService, bool useStopwatchProvider, bool useBackgroundService, bool useBackgroundSyncService, bool useSchedulerProvider, bool useNotificationService, bool useRemoteConfigService, bool useIntentDonationService, bool useApplicationShortcutCreator, bool usePrivateSharedStorageService, bool useSuggestionProviderContainer) { var version = useVersion ? Version.Parse("1.0") : null; var agent = userAgent ? new UserAgent("Some Client", "1.0") : null; var scheduler = useScheduler ? Substitute.For <IScheduler>() : null; var database = useDatabase ? Substitute.For <ITogglDatabase>() : null; var apiFactory = useApiFactory ? Substitute.For <IApiFactory>() : null; var timeService = useTimeService ? Substitute.For <ITimeService>() : null; var platformInfo = usePlatformInfo ? Substitute.For <IPlatformInfo>() : null; var ratinService = useRatingService ? Substitute.For <IRatingService>() : null; var googleService = useGoogleService ? Substitute.For <IGoogleService>() : null; var licenseProvider = useLicenseProvider ? Substitute.For <ILicenseProvider>() : null; var analyticsService = useAnalyticsService ? Substitute.For <IAnalyticsService>() : null; var stopwatchProvider = useStopwatchProvider ? Substitute.For <IStopwatchProvider>() : null; var backgroundService = useBackgroundService ? Substitute.For <IBackgroundService>() : null; var backgroundSyncService = useBackgroundSyncService ? Substitute.For <IBackgroundSyncService>() : null; var notificationService = useNotificationService ? Substitute.For <INotificationService>() : null; var remoteConfigService = useRemoteConfigService ? Substitute.For <IRemoteConfigService>() : null; var intentDonationService = useIntentDonationService ? Substitute.For <IIntentDonationService>() : null; var applicationShortcutCreator = useApplicationShortcutCreator ? Substitute.For <IApplicationShortcutCreator>() : null; var suggestionProviderContainer = useSuggestionProviderContainer ? Substitute.For <ISuggestionProviderContainer>() : null; var privateSharedStorageService = usePrivateSharedStorageService ? Substitute.For <IPrivateSharedStorageService>() : null; var schedulerProvider = useSchedulerProvider ? Substitute.For <ISchedulerProvider>() : null; Action tryingToConstructWithEmptyParameters = () => TogglFoundation .ForClient(agent, version) .WithDatabase(database) .WithScheduler(scheduler) .WithApiFactory(apiFactory) .WithTimeService(timeService) .WithPlatformInfo(platformInfo) .WithRatingService(ratinService) .WithGoogleService(googleService) .WithLicenseProvider(licenseProvider) .WithAnalyticsService(analyticsService) .WithStopwatchProvider(stopwatchProvider) .WithBackgroundService(backgroundService) .WithBackgroundSyncService(backgroundSyncService) .WithSchedulerProvider(schedulerProvider) .WithPlatformInfo(platformInfo) .WithNotificationService(notificationService) .WithRemoteConfigService(remoteConfigService) .WithIntentDonationService(intentDonationService) .WithApplicationShortcutCreator(applicationShortcutCreator) .WithSuggestionProviderContainer(suggestionProviderContainer) .WithPrivateSharedStorageService(privateSharedStorageService) .Build(); tryingToConstructWithEmptyParameters.Should().Throw <Exception>(); }
public static MvvmCrossFoundation.Builder StartRegisteringPlatformServices(this TogglFoundation foundation) => new MvvmCrossFoundation.Builder(foundation);
protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app) { #if !USE_PRODUCTION_API System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; #endif const string clientName = "Daneel"; var version = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString(); var database = new Database(); var scheduler = Scheduler.Default; var timeService = new TimeService(scheduler); var topViewControllerProvider = (ITopViewControllerProvider)Presenter; var mailService = new MailService(topViewControllerProvider); var dialogService = new DialogService(topViewControllerProvider); var platformConstants = new PlatformConstants(); var suggestionProviderContainer = new SuggestionProviderContainer( new MostUsedTimeEntrySuggestionProvider(database, timeService, maxNumberOfSuggestions) ); var appVersion = Version.Parse(version); var userAgent = new UserAgent(clientName, version); var keyValueStorage = new UserDefaultsStorage(); var settingsStorage = new SettingsStorage(Version.Parse(version), keyValueStorage); var foundation = TogglFoundation .ForClient(userAgent, appVersion) .WithDatabase(database) .WithScheduler(scheduler) .WithMailService(mailService) .WithTimeService(timeService) .WithApiEnvironment(environment) .WithGoogleService <GoogleService>() .WithRatingService <RatingService>() .WithLicenseProvider <LicenseProvider>() .WithAnalyticsService(analyticsService) .WithPlatformConstants(platformConstants) .WithRemoteConfigService <RemoteConfigService>() .WithApiFactory(new ApiFactory(environment, userAgent)) .WithBackgroundService(new BackgroundService(timeService)) .WithApplicationShortcutCreator <ApplicationShortcutCreator>() .WithSuggestionProviderContainer(suggestionProviderContainer) .StartRegisteringPlatformServices() .WithDialogService(dialogService) .WithLastTimeUsageStorage(settingsStorage) .WithBrowserService <BrowserService>() .WithKeyValueStorage(keyValueStorage) .WithUserPreferences(settingsStorage) .WithOnboardingStorage(settingsStorage) .WithNavigationService(navigationService) .WithAccessRestrictionStorage(settingsStorage) .WithPasswordManagerService <OnePasswordService>() .WithErrorHandlingService(new ErrorHandlingService(navigationService, settingsStorage)) .WithFeedbackService(new FeedbackService(userAgent, mailService, dialogService, platformConstants)) .Build(); foundation.RevokeNewUserIfNeeded().Initialize(); base.InitializeApp(pluginManager, app); }
public Builder(TogglFoundation foundation) { Ensure.Argument.IsNotNull(foundation, nameof(foundation)); Foundation = foundation; }
protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app) { #if !USE_PRODUCTION_API System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; #endif const string clientName = "Daneel"; const string remoteConfigDefaultsFileName = "RemoteConfigDefaults"; var version = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString(); var database = new Database(); var scheduler = Scheduler.Default; var timeService = new TimeService(scheduler); var topViewControllerProvider = (ITopViewControllerProvider)Presenter; var dialogService = new DialogServiceIos(topViewControllerProvider); var platformInfo = new PlatformInfoIos(); var suggestionProviderContainer = new SuggestionProviderContainer( new MostUsedTimeEntrySuggestionProvider(database, timeService, maxNumberOfSuggestions) ); var intentDonationService = new IntentDonationServiceIos(); var privateSharedStorageService = new PrivateSharedStorageServiceIos(); var appVersion = Version.Parse(version); var keyValueStorage = new UserDefaultsStorageIos(); var permissionsService = new PermissionsServiceIos(); var userAgent = new UserAgent(clientName, version); var settingsStorage = new SettingsStorage(Version.Parse(version), keyValueStorage); var remoteConfigService = new RemoteConfigServiceIos(); remoteConfigService.SetupDefaults(remoteConfigDefaultsFileName); var schedulerProvider = new IOSSchedulerProvider(); var calendarService = new CalendarServiceIos(permissionsService); var notificationService = new NotificationServiceIos(permissionsService, timeService); var backgroundSyncService = new BackgroundSyncServiceIos(); var backgroundService = new BackgroundService(timeService, analyticsService); var automaticSyncingService = new AutomaticSyncingService(backgroundService, timeService, analyticsService); var errorHandlingService = new ErrorHandlingService(navigationService, settingsStorage); var foundation = TogglFoundation .ForClient(userAgent, appVersion) .WithDatabase(database) .WithScheduler(scheduler) .WithTimeService(timeService) .WithApiEnvironment(environment) .WithGoogleService <GoogleServiceIos>() .WithRatingService <RatingServiceIos>() .WithLicenseProvider <LicenseProviderIos>() .WithAnalyticsService(analyticsService) .WithSchedulerProvider(schedulerProvider) .WithRemoteConfigService(remoteConfigService) .WithNotificationService(notificationService) .WithApiFactory(new ApiFactory(environment, userAgent)) .WithBackgroundService(backgroundService) .WithAutomaticSyncingService(automaticSyncingService) .WithApplicationShortcutCreator(new ApplicationShortcutCreator()) .WithSuggestionProviderContainer(suggestionProviderContainer) .WithIntentDonationService(intentDonationService) .WithStopwatchProvider <FirebaseStopwatchProviderIos>() .WithPrivateSharedStorageService(privateSharedStorageService) .WithPlatformInfo(platformInfo) .WithBackgroundSyncService(backgroundSyncService) .StartRegisteringPlatformServices() .WithDialogService(dialogService) .WithLastTimeUsageStorage(settingsStorage) .WithBrowserService <BrowserServiceIos>() .WithKeyValueStorage(keyValueStorage) .WithUserPreferences(settingsStorage) .WithCalendarService(calendarService) .WithOnboardingStorage(settingsStorage) .WithNavigationService(navigationService) .WithPermissionsService(permissionsService) .WithAccessRestrictionStorage(settingsStorage) .WithPasswordManagerService <OnePasswordServiceIos>() .WithErrorHandlingService(errorHandlingService) .WithSyncErrorHandlingService(new SyncErrorHandlingService(errorHandlingService)) .WithRxActionFactory(new RxActionFactory(schedulerProvider)) .Build(); foundation.RevokeNewUserIfNeeded().Initialize(); base.InitializeApp(pluginManager, app); }
protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app) { const string clientName = "Giskard"; var packageInfo = ApplicationContext.PackageManager.GetPackageInfo(ApplicationContext.PackageName, 0); var version = packageInfo.VersionName; var sharedPreferences = ApplicationContext.GetSharedPreferences(clientName, FileCreationMode.Private); var database = new Database(); var scheduler = Scheduler.Default; var timeService = new TimeService(scheduler); var backgroundService = new BackgroundService(timeService, analyticsService); var suggestionProviderContainer = new SuggestionProviderContainer( new MostUsedTimeEntrySuggestionProvider(database, timeService, maxNumberOfSuggestions) ); var appVersion = Version.Parse(version); var userAgent = new UserAgent(clientName, version); var dialogService = new DialogServiceAndroid(); var platformInfo = new PlatformInfoAndroid(); var keyValueStorage = new SharedPreferencesStorageAndroid(sharedPreferences); var settingsStorage = new SettingsStorage(appVersion, keyValueStorage); var schedulerProvider = new AndroidSchedulerProvider(); var permissionsService = new PermissionsServiceAndroid(); var calendarService = new CalendarServiceAndroid(permissionsService); var automaticSyncingService = new AutomaticSyncingService(backgroundService, timeService); var errorHandlingService = new ErrorHandlingService(navigationService, settingsStorage); ApplicationContext.RegisterReceiver(new TimezoneChangedBroadcastReceiver(timeService), new IntentFilter(Intent.ActionTimezoneChanged)); var dataSource = new TogglDataSource( database, timeService, analyticsService); var foundation = TogglFoundation .ForClient(userAgent, appVersion) .WithDatabase(database) .WithDataSource(dataSource) .WithScheduler(scheduler) .WithTimeService(timeService) .WithApiEnvironment(environment) .WithGoogleService <GoogleServiceAndroid>() .WithRatingService(new RatingServiceAndroid(ApplicationContext)) .WithLicenseProvider <LicenseProviderAndroid>() .WithAnalyticsService(analyticsService) .WithSchedulerProvider(schedulerProvider) .WithPlatformInfo(platformInfo) .WithNotificationService <NotificationServiceAndroid>() .WithRemoteConfigService <RemoteConfigServiceAndroid>() .WithApiFactory(new ApiFactory(environment, userAgent)) .WithBackgroundService(backgroundService) .WithAutomaticSyncingService(automaticSyncingService) .WithSuggestionProviderContainer(suggestionProviderContainer) .WithApplicationShortcutCreator(new ApplicationShortcutCreator(ApplicationContext)) .WithStopwatchProvider <FirebaseStopwatchProviderAndroid>() .WithIntentDonationService(new NoopIntentDonationServiceAndroid()) .WithPrivateSharedStorageService(new NoopPrivateSharedStorageServiceAndroid()) .WithBackgroundSyncService <BackgroundSyncServiceAndroid>() .StartRegisteringPlatformServices() .WithDialogService(dialogService) .WithLastTimeUsageStorage(settingsStorage) .WithBrowserService <BrowserServiceAndroid>() .WithCalendarService(calendarService) .WithKeyValueStorage(keyValueStorage) .WithUserPreferences(settingsStorage) .WithOnboardingStorage(settingsStorage) .WithNavigationService(navigationService) .WithPermissionsService(permissionsService) .WithAccessRestrictionStorage(settingsStorage) .WithErrorHandlingService(errorHandlingService) .WithSyncErrorHandlingService(new SyncErrorHandlingService(errorHandlingService)) .WithRxActionFactory(new RxActionFactory(schedulerProvider)) .Build(); foundation.RevokeNewUserIfNeeded().Initialize(); ensureDataSourceInitializationIfLoggedIn(); createApplicationLifecycleObserver(backgroundService); base.InitializeApp(pluginManager, app); }