-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16cd3b3
commit 749453a
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
using Realms; | ||
using System; | ||
using Microsoft.VisualBasic; | ||
using NUnit.Framework; | ||
using NUnit.Framework.Internal; | ||
using Realms; | ||
using Realms.Sync; | ||
|
||
namespace Examples | ||
{ | ||
public class DataSyncExamples | ||
{ | ||
Realm realm; | ||
App app; | ||
Realms.Sync.User user; | ||
FlexibleSyncConfiguration config; | ||
|
||
public void TestsCustomSetter() | ||
[OneTimeSetUp] | ||
public void Setup() | ||
{ | ||
|
||
const string myRealmAppId = Config.FSAppId; | ||
app = App.Create(myRealmAppId); | ||
user = app.LogInAsync( | ||
Credentials.Anonymous()).Result; | ||
|
||
config = new FlexibleSyncConfiguration(user) | ||
; | ||
} | ||
|
||
[Test] | ||
public void StartStopSession() | ||
{ | ||
realm = Realm.GetInstance(); | ||
// :snippet-start: pause-synced-realm | ||
realm = Realm.GetInstance(config); | ||
var session = realm.SyncSession; | ||
session.Stop(); | ||
//later... | ||
session.Start(); | ||
// :snippet-end: | ||
} | ||
|
||
[Test] | ||
public void GetSessionAndState(){ | ||
// :snippet-start: get-sync-session | ||
realm = Realm.GetInstance(config); | ||
var session = realm.SyncSession; | ||
// :snippet-end: | ||
// :snippet-start: get-session-state | ||
var sessionState = session.State; | ||
if (sessionState == SessionState.Active){ | ||
Console.WriteLine("The session is active"); | ||
} else { | ||
Console.WriteLine("The session is inactive"); | ||
} | ||
// :snippet-end: | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
source/examples/generated/dotnet/DataSyncExamples.snippet.get-session-state.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var sessionState = session.State; | ||
if (sessionState == SessionState.Active){ | ||
Console.WriteLine("The session is active"); | ||
} else { | ||
Console.WriteLine("The session is inactive"); | ||
} |
2 changes: 2 additions & 0 deletions
2
source/examples/generated/dotnet/DataSyncExamples.snippet.get-sync-session.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
realm = Realm.GetInstance(config); | ||
var session = realm.SyncSession; |
1 change: 1 addition & 0 deletions
1
source/examples/generated/dotnet/DataSyncExamples.snippet.pause-synced-realm.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
realm = Realm.GetInstance(config); | ||
var session = realm.SyncSession; | ||
session.Stop(); | ||
//later... | ||
|