Exemple #1
0
        public void App_WithCustomLogger_LogsSyncOperations(LogLevel logLevel)
        {
            SyncTestHelpers.RunBaasTestAsync(async() =>
            {
                var logBuilder = new StringBuilder();

                var appConfig          = SyncTestHelpers.GetAppConfig();
                appConfig.LogLevel     = logLevel;
                appConfig.CustomLogger = (message, level) =>
                {
                    lock (logBuilder)
                    {
                        logBuilder.AppendLine($"[{level}] {message}");
                    }
                };

                var app = CreateApp(appConfig);

                var config      = await GetIntegrationConfigAsync(Guid.NewGuid().ToString());
                using var realm = await GetRealmAsync(config);
                realm.Write(() =>
                {
                    realm.Add(new PrimaryKeyStringObject {
                        StringProperty = Guid.NewGuid().ToString()
                    });
                });

                await WaitForUploadAsync(realm);

                var log = logBuilder.ToString();

                Assert.That(log, Does.Contain($"[{logLevel}]"));
                Assert.That(log, Does.Not.Contain($"[{logLevel - 1}]"));
            });
        }
Exemple #2
0
        public void RealmConfiguration_WithCustomLogger_LogsSyncOperations(LogLevel logLevel)
        {
            SyncTestHelpers.RunBaasTestAsync(async() =>
            {
                Logger.LogLevel = logLevel;
                var logger      = new Logger.InMemoryLogger();
                Logger.Default  = logger;

                var appConfig = SyncTestHelpers.GetAppConfig();

                var app = CreateApp(appConfig);

                var config      = await GetIntegrationConfigAsync(Guid.NewGuid().ToString());
                using var realm = await GetRealmAsync(config);
                realm.Write(() =>
                {
                    realm.Add(new PrimaryKeyStringObject {
                        StringProperty = Guid.NewGuid().ToString()
                    });
                });

                await WaitForUploadAsync(realm);

                var log = logger.GetLog();

                Assert.That(log, Does.Contain($"{logLevel}:"));
                Assert.That(log, Does.Not.Contain($"{logLevel - 1}:"));
            });
        }
Exemple #3
0
        protected async Task <SyncConfiguration> GetIntegrationConfigAsync(Guid?partition, App app = null, string optionalPath = null)
        {
            app ??= App.Create(SyncTestHelpers.GetAppConfig(AppConfigType.UUIDPartitionKey));

            var user = await GetUserAsync(app);

            return(UpdateConfig(new SyncConfiguration(partition, user, optionalPath)));
        }
Exemple #4
0
        protected App CreateApp(AppConfiguration config = null)
        {
            config ??= SyncTestHelpers.GetAppConfig();

            var app = App.Create(config);

            _apps.Add(app);

            if (_defaultApp == null)
            {
                _defaultApp = app;
            }

            return(app);
        }