private async Task <Uri> CreateRealm(Action <Realm> assignRoles = null, bool addObjects = true) { var uri = SyncTestHelpers.RealmUri(Guid.NewGuid().ToString()); var admin = await SyncTestHelpers.GetAdminUserAsync(); var config = new SyncConfiguration(admin, uri) { ObjectClasses = new[] { typeof(ObjectWithPermissions) }, IsPartial = true }; using (var realm = GetRealm(config)) { var objects = realm.All <ObjectWithPermissions>(); var subscription = await SubscribeToObjectsAsync(realm); if (addObjects) { Assert.That(subscription.Results.Count(), Is.EqualTo(0)); AddObjectsToRealm(realm, new[] { 1, 2, 3 }); await WaitForSyncAsync(realm); Assert.That(subscription.Results.Count(), Is.EqualTo(3)); } if (assignRoles != null) { realm.Write(() => { assignRoles(realm); }); } await WaitForSyncAsync(realm); } return(uri); }