public void Session_DivergingHistories_ShouldRaiseClientResetException() { AsyncContext.Run(async() => { var config = await SyncTestHelpers.GetFakeConfigAsync(); ClientResetException error = null; using (var realm = GetRealm(config)) { var session = GetSession(realm); var result = await SyncTestHelpers.SimulateSessionErrorAsync <ClientResetException>(session, ErrorCode.DivergingHistories, "Fake client reset is required"); CleanupOnTearDown(result.Item1); error = result.Item2; } Assert.That(error.BackupFilePath, Is.Not.Null); Assert.That(error.BackupFilePath, Does.Contain(Path.Combine("io.realm.object-server-recovered-realms", "recovered_realm"))); Assert.That(File.Exists(error.BackupFilePath), Is.False); var clientResetSuccess = error.InitiateClientReset(); Assert.That(clientResetSuccess, Is.True); Assert.That(File.Exists(error.BackupFilePath), Is.True); }); }
public void Session_Error_ShouldPassCorrectSession() { AsyncContext.Run(async() => { var config = await SyncTestHelpers.GetFakeConfigAsync(); using (var realm = GetRealm(config)) { var session = GetSession(realm); const ErrorCode code = (ErrorCode)102; const string message = "Some fake error has occurred"; var result = await SyncTestHelpers.SimulateSessionErrorAsync <SessionException>(session, code, message); CleanupOnTearDown(result.Item1); var error = result.Item2; Assert.That(error.Message, Is.EqualTo(message)); Assert.That(error.ErrorCode, Is.EqualTo(code)); var errorSession = result.Item1; Assert.That(errorSession.ServerUri, Is.EqualTo(((SyncConfigurationBase)realm.Config).ServerUri)); } }); }