public void DefaultConfiguration_WhenMoreThanOneUserLoggedIn_ShouldThrow() { AsyncContext.Run(async() => { await SyncTestHelpers.GetFakeUserAsync(); await SyncTestHelpers.GetFakeUserAsync(); Assert.That(() => new QueryBasedSyncConfiguration(), Throws.TypeOf <ArgumentException>().And.Message.Contains("The user must be explicitly specified when the number of logged-in users is not 1.")); }); }
public void DefaultConfiguration_WhenOneUserLoggedIn_ShouldWork(string userScheme, string realmScheme) { AsyncContext.Run(async() => { await SyncTestHelpers.GetFakeUserAsync(scheme: userScheme); var config = new SyncConfiguration(); Assert.That(config.IsPartial); Assert.That(config.ServerUri.Scheme, Is.EqualTo(realmScheme)); Assert.That(config.ServerUri.Segments, Is.EqualTo(new[] { "/", "default" })); }); }
public void UserAllLoggedIn_WhenThereIsOneUser_ShouldReturnThatUser() { AsyncContext.Run(async() => { var user = await SyncTestHelpers.GetFakeUserAsync(); var users = User.AllLoggedIn; Assert.That(users.Length, Is.EqualTo(1)); Assert.That(users[0], Is.EqualTo(user)); }); }
public void SyncConfiguration_WithEncryptionKey_DoesntThrow() { AsyncContext.Run(async() => { var user = await SyncTestHelpers.GetFakeUserAsync(); var key = Enumerable.Range(0, 63).Select(i => (byte)i).ToArray(); var config = new SyncConfiguration(user, new Uri("realm://foobar")) { EncryptionKey = TestHelpers.GetEncryptionKey(key) }; Assert.That(() => GetRealm(config), Throws.Nothing); }); }
public void UserAllLoggedIn_WhenThereAreNineUsers_ShouldReturnAllOfThem() { AsyncContext.Run(async() => { var users = new List <User>(); for (var i = 0; i < 9; i++) { users.Add(await SyncTestHelpers.GetFakeUserAsync()); } var current = User.AllLoggedIn; Assert.That(current, Is.EquivalentTo(users)); }); }
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>()); }); }
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); }); }
public void Realm_GetSession_WhenSyncedRealm() { AsyncContext.Run(async() => { var user = await SyncTestHelpers.GetFakeUserAsync(); var serverUri = new Uri("realm://localhost:9080/foobar"); var config = new FullSyncConfiguration(serverUri, user); using (var realm = GetRealm(config)) { var session = GetSession(realm); Assert.That(session.User, Is.EqualTo(user)); Assert.That(session.ServerUri, Is.EqualTo(serverUri)); } }); }
public void SyncConfiguration_WithoutPath() { AsyncContext.Run(async() => { var user = await SyncTestHelpers.GetFakeUserAsync(); var serverUri = new Uri("realm://localhost:9080/foobar"); var config = new SyncConfiguration(user, serverUri); var file = new FileInfo(config.DatabasePath); Assert.That(file.Exists, Is.False); using (var realm = GetRealm(config)) { } file = new FileInfo(config.DatabasePath); Assert.That(file.Exists); }); }
public void SyncConfiguration_WithEncryptionKey_DoesntThrow() { AsyncContext.Run(async() => { var user = await SyncTestHelpers.GetFakeUserAsync(); var key = new byte[64]; for (var i = 0; i < key.Length; i++) { key[i] = (byte)i; } var config = new SyncConfiguration(user, new Uri("realm://foobar")) { EncryptionKey = key }; Assert.That(() => GetRealm(config), Throws.Nothing); }); }
public void SyncConfiguration_WithAbsolutePath() { AsyncContext.Run(async() => { var user = await SyncTestHelpers.GetFakeUserAsync(); var serverUri = new Uri("realm://localhost:9080/foobar"); var path = Path.GetTempFileName(); var config = new SyncConfiguration(user, serverUri, path); Realm.DeleteRealm(config); var file = new FileInfo(config.DatabasePath); Assert.That(file.Exists, Is.False); using (var realm = GetRealm(config)) { } file = new FileInfo(config.DatabasePath); Assert.That(file.Exists); Assert.That(config.DatabasePath, Is.EqualTo(path)); }); }