public void Session_Error_ShouldPassCorrectSession() { AsyncContext.Run(async() => { var realm = await SyncTestHelpers.GetFakeRealm(isUserAdmin: true); var session = realm.GetSession(); const ErrorCode code = (ErrorCode)102; const string message = "Some fake error has occurred"; var result = await SyncTestHelpers.SimulateSessionError <SessionException>(session, code, message); 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(((SyncConfiguration)realm.Config).ServerUri)); realm.Dispose(); Realm.DeleteRealm(realm.Config); }); }
public void Session_DivergingHistories_ShouldRaiseClientResetException() { AsyncContext.Run(async() => { var realm = await SyncTestHelpers.GetFakeRealm(isUserAdmin: true); var session = realm.GetSession(); var result = await SyncTestHelpers.SimulateSessionError <ClientResetException>(session, ErrorCode.DivergingHistories, "Fake client reset is required"); var error = result.Item2; Assert.That(error.BackupFilePath, Is.Not.Null); Assert.That(error.BackupFilePath, Does.Contain("io.realm.object-server-recovered-realms/recovered_realm")); Assert.That(File.Exists(error.BackupFilePath), Is.False); realm.Dispose(); var clientResetSuccess = error.InitiateClientReset(); Assert.That(clientResetSuccess, Is.True); Assert.That(File.Exists(error.BackupFilePath), Is.True); }); }