Skip to content

Commit

Permalink
add tests for sync session
Browse files Browse the repository at this point in the history
  • Loading branch information
MongoCaleb committed Jul 22, 2024
1 parent 16cd3b3 commit 749453a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
43 changes: 40 additions & 3 deletions examples/dotnet/Examples/DataSyncExamples.cs
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:
}
}
}
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");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
realm = Realm.GetInstance(config);
var session = realm.SyncSession;
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...
Expand Down

0 comments on commit 749453a

Please sign in to comment.