Example #1
0
        protected override void CustomSetUp()
        {
            base.CustomSetUp();

            if (!string.IsNullOrEmpty(SyncTestHelpers.ProfessionalFeatureToken))
            {
                SyncConfiguration.SetFeatureToken(SyncTestHelpers.ProfessionalFeatureToken);
            }

            var defaultFolder = InteropConfig.DefaultStorageFolder;

            if (TestHelpers.IsWindows)
            {
                // We do this to reduce the length of the folders in Windows
                var testsIndex = defaultFolder.IndexOf("\\Tests\\");
                var docsIndex  = defaultFolder.IndexOf("\\Documents") + 1;

                if (testsIndex > -1 && docsIndex > testsIndex)
                {
                    defaultFolder = Path.Combine(defaultFolder.Substring(0, testsIndex), defaultFolder.Substring(docsIndex))
                                    .Replace("\\Documents", "\\D");

                    Directory.CreateDirectory(defaultFolder);
                }
            }

            SharedRealmHandleExtensions.ConfigureFileSystem(persistence, null, false, defaultFolder);
        }
Example #2
0
        private static async Task MainAsync()
        {
            SyncConfiguration.SetFeatureToken(Constants.FeatureToken);

            var credentials = Credentials.UsernamePassword(Constants.RosUsername, Constants.RosPassword, createUser: false);
            var admin       = await User.LoginAsync(credentials, new Uri($"http://{Constants.RosUrl}"));

            // Hack to create synchronized Realm the first time it's used
            var syncConfig = new SyncConfiguration(admin, new Uri($"realm://{Constants.RosUrl}/{Constants.FeedbackRealm}"));

            using (var realm = Realm.GetInstance(syncConfig))
            {
                if (!realm.All <Foo>().Any())
                {
                    realm.Write(() => realm.Add(new Foo()));
                    await realm.GetSession().WaitForUploadAsync();

                    await admin.ApplyPermissionsAsync(PermissionCondition.Default, syncConfig.ServerUri.ToString(), AccessLevel.Write);
                }
            }

            var config = new NotifierConfiguration(admin)
            {
                Handlers         = { new FeedbackHandler() },
                WorkingDirectory = Path.Combine(Directory.GetCurrentDirectory(), Constants.NotifierDirectory)
            };

            using (var notifier = await Notifier.StartAsync(config))
            {
                do
                {
                    Console.WriteLine("Type in 'exit' to quit the app.");
                }while (Console.ReadLine() != "exit");
            }
        }
Example #3
0
        protected override void CustomSetUp()
        {
            base.CustomSetUp();

            if (!string.IsNullOrEmpty(SyncTestHelpers.ProfessionalFeatureToken))
            {
                SyncConfiguration.SetFeatureToken(SyncTestHelpers.ProfessionalFeatureToken);
            }

            SharedRealmHandleExtensions.ConfigureFileSystem(persistence, null, false);
        }
Example #4
0
        public void FeatureToken_WhenDeveloper_PreventsSync()
        {
            if (!TestHelpers.IsLinux)
            {
                Assert.Ignore("Feature tokens are not required on non-linux platforms");
            }

            AsyncContext.Run(async() =>
            {
                var user   = await SyncTestHelpers.GetFakeUserAsync();
                var config = new SyncConfiguration(user, new Uri("realm://foobar"));

                SyncConfiguration.SetFeatureToken(SyncTestHelpers.DeveloperFeatureToken);
                Assert.That(() => GetRealm(config), Throws.TypeOf <RealmFeatureUnavailableException>());
            });
        }
Example #5
0
        public void FeatureTokens_WhenPaid_AllowSync(string token)
        {
            if (!TestHelpers.IsLinux)
            {
                Assert.Ignore("Feature tokens are not required on non-linux platforms");
            }

            AsyncContext.Run(async() =>
            {
                var user   = await SyncTestHelpers.GetFakeUserAsync();
                var config = new SyncConfiguration(user, new Uri("realm://foobar"));

                SyncConfiguration.SetFeatureToken(token);
                Assert.That(() => GetRealm(config), Throws.Nothing);
            });
        }