Exemple #1
0
 public static void DisposeEditModeInstance()
 {
     if (Application.isPlaying == false)
     {
         //Somehow this crashes Unity lol... the network is left running in the other thread it seems.
         appInstance?.Dispose();
     }
 }
Exemple #2
0
        public IEnumerator Terminate_ShouldWork()
        {
            var appOptions = new AppOptions();

            appOptions.ProjectId = "test-terminate"; // Setting a ProjectId is required (b/158838266).
            FirebaseApp app          = FirebaseApp.Create(appOptions, "App1");
            var         db1          = FirebaseFirestore.GetInstance(app);
            var         doc          = db1.Document("abc/123");
            var         accumulator  = new EventAccumulator <DocumentSnapshot>();
            var         registration = doc.Listen(accumulator.Listener);

            // Multiple calls to terminate should go through.
            yield return(AwaitSuccess(db1.TerminateAsync()));

            yield return(AwaitSuccess(db1.TerminateAsync()));

            // Make sure calling registration.Stop multiple times after termination works.
            registration.Stop();
            registration.Stop();

            // TODO(b/149105903) Uncomment this line when a C# exception can be thrown here.
            // Assert.Throws<NullReferenceException>(() => db1.DisableNetworkAsync());

            // Create a new functional instance.
            var db2 = FirebaseFirestore.GetInstance(app);

            Assert.That(db2, Is.Not.SameAs(db1));
            yield return(AwaitSuccess(db2.DisableNetworkAsync()));

            yield return(AwaitSuccess(db2.EnableNetworkAsync()));

            app.Dispose();
            // TODO(b/183604785): App.Dispose really should leads to Firestore terminated, a NRE here is
            // not ideal, but serves the purpose for now. Ideally, it should throw an exception
            // telling user it is terminated.
            Assert.Throws <NullReferenceException>(() => db2.DisableNetworkAsync());
        }